Hello,
Everything is in the title. I'm looking for a feature similar to the drupal issues lists: I want to be able to theme rows (unformatted style) according to taxonomy terms? I guess I have to change my views-view-unformatted.tlp.php but how?
Thanks

Comments

dawehner’s picture

Category: feature » support

- changing to support request.

there are serveral way to achive this.

first you could create a your unformatted tpl and add something like this at the beginning.

<?php
foreach ($rows as $id => $item) {
  $node = node_load($id);
  $terms = array_keys($node->taxonomy);
  foreach ($terms as $term) {
    $classes[$id] .= "term-line-$term";
  } 
}
?>
spasmody’s picture

that doesn't work because $node should be an array:

# warning: array_keys() [function.array-keys]: The first argument should be an array in .../sites/all/modules/views/theme/views-view-unformatted.tpl.php on line 13.
# warning: Invalid argument supplied for foreach() in .../sites/all/modules/views/theme/views-view-unformatted.tpl.php on line 14.

What's wrong?

dawehner’s picture

<?php
<?php
foreach ($rows as $id => $item) {
  $node = node_load($item->nid);
  $terms = array_keys($node->taxonomy);
  foreach ($terms as $term) {
    $classes[$id] .= "term-line-$term";
  }
}
?>

Perhaps this works for you.

esmerel’s picture

Status: Active » Fixed

No response to potential solution for more than 30 days.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.