function buildBranch($parent_id, $level, $submenu=true, $parent_link='')
{
$result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '' );
if (($this->data[$parent_id])) {
foreach($this->data[$parent_id] as $category_id => $category) {
$category_link = $parent_link . $category_id;
if (($this->data[$category_id])) {
$result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
} else {
$result .= sprintf($this->child_start_string, '');
}
//$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
$result .= str_repeat($this->spacer_string, $this->spacer_multiplier * 1) . ($parent_link? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">': '');
$result .= $category['name'];
//$result .= '</a>';
$result .= ($parent_link? '</a>': '');
if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
$result .= $this->buildBranch($category_id, $level+1, $submenu, $category_link . '_');
}
$result .= $this->child_end_string;
}
}
$result .= $this->parent_group_end_string;
return $result;
}
Add as shown in red to two lines:
($parent_link? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">': '')
($parent_link? '</a>': '')
This will disable the link if $parent_link is blank (the current category is a top category).
Please test and let me know how it works for you. If you have sub-subcats, this would not disable links on their parents (subcats). That would require a different approach, but might be achievable without much more complexity.