My theme currently only renders the terms of the last used vocabulary correctly into the designated div, all other terms are incorrectly rendered into the node-content. I already know where to look, I just couldn't figure out how to fix this since I'm not really familiar with PHP and Drupal theming.
This is the method responsible for returning the taxonomy terms used for rendering (and hiding):
function get_terms_D7($content) {
$result = NULL;
foreach (array_keys($content) as $name) {
$$name = & $content[$name];
$field_type = NULL;
if (is_array($content[$name])) {
if (isset($content[$name]['#field_type']))
$field_type = $content[$name]['#field_type'];
} else if (is_object($content[$name])) {
if (isset($content[$name]->field_type))
$field_type = $content[$name]->field_type;
}
if ($field_type == NULL || $field_type != "taxonomy_term_reference") continue;
$result = $content[$name]; //this seems to be the issue, only the terms of last vocabulary will be returned
}
return $result;
}
The results are used for rendering and, before that, hiding (simplified example):
$terms = get_terms_D7($content); // '$content' is the Drupal variable in my node.tpl.php
//rendering
$output = '<div class="tags">' . render($terms) . '</div>';
//hiding
hide($content[$terms['#field_name']]);
As you can see, it's logical why I'm only getting the terms of the last vocab out of this method. I already tried all kinds of things like $result .= $content[$name]
instead of just assigning the last value of the loop. Since the result is an array, I then tried methods like array_push($result, $content[$name])
or array_merge($result, $content[$name])
instead. I also tried to add each single value of the the array:
if ($result == NULL) {
$result = $content[$name];
} else {
foreach ($content[$name] as $value) {
array_push($result, $value);
}
}
But without a deeper knowledge of Drupal theming and the usage of fields and variabels in the tpl.php-files I'm afraid I'm stuck.
So, I need this method to return the assigned terms of all of the used vocabs, not just the last one. I'd appreciate any help, thanks!