Postponed (maintainer needs more info)
Project:
Taxonomy context
Version:
5.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Mar 2007 at 13:51 UTC
Updated:
26 Feb 2009 at 17:57 UTC
When a term has no sub-terms and/or no sub-nodes, it should not be rendered as <li class="collapsed"> or <li class="expanded">, but as <li class="leaf">. This currently does not happen.
Here is a code snippet from a version of taxonomy_context_menu_tree() that fixes this problem (sorry, I do not know how to work with CVS):
if ($terms) {
foreach ($terms as $term) {
$params = array('title' => $term->description ? strip_tags(node_teaser($term->description)) : t('View this section'));
$link = l($term->name, taxonomy_term_path($term), $params);
if (in_array($term->tid, $parents)) {
if (count(taxonomy_get_children($term->tid, $vid)))
{
$output .= '<li class="expanded">' . $link . "\n";
$output .= taxonomy_context_menu_tree($vid, $term->tid, FALSE) ."\n";
}
else
$output .= '<li class="leaf">' . $link . "\n";
if (variable_get('taxonomy_context_block_node', TAXONOMY_CONTEXT_NODE_BLOCK_NONE)) {
$output .= '<ul class="menu">'. taxonomy_context_show_nodes($term->tid) ."</ul>\n";
}
$output .= "</li>\n";
}
else {
$output .= (count(taxonomy_get_children($term->tid, $vid))) ?
'<li class="collapsed">' . $link . "</li>\n" :
'<li class="leaf">' . $link . "</li>\n";
}
}
}
Note that the many calls to taxonomy_get_children() might bog everything down. However I couldn't find a better way because unfortunately your code is not very well documented (or hardly documented at all I should say).
Comments
Comment #1
Dio-1 commentedSeems that drupal.org has messed up > and < (they displayed correctly when I previewed the issue). Just replace them with the correct characters in your imagination when reading the code.
Comment #2
nancydruIt looks to me like this is fixed in Version 2.