Looks like this patch http://drupal.org/node/364717#comment-1237256 which implemented the following change has introduced a new bug.

-        if ($term_trails[$term->tid]) {
+        if (isset($term_trails[$term->tid])) {

Because of the isset() statement menutrails fails to assign a trail based on node type if the page/node in question has any vocabulary associated with it.

The $term_trails array is populated regardless of wether or not the page in question is making use of the menutrails taxonomy settings or not. You end up with an array where the key is the term id, and the value is either blank, or the path of the menu item that you have choosen to use as a parent for this particular term.

$term_trails[1] = '';
$term_trails[2] = 'some/path';
$term_trails[3] = ''

Attached patch fixes this by replacing isset() with !empty()

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rwd’s picture

Confirming that this issue:

  1. is critical as it prevents menu trails being highlighted under the conditions described by eojthebrave;
  2. is still present in the 6.x-1.x-dev (2009-Aug-18) release; and
  3. is fixed in this release by the patch.
Les Lim’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed. As this is a critical problem and a near-trivial tweak of the code, I'm inclined to mark this RTBC.

jenpasch’s picture

6.x-1.x-dev patched with patch above.
Uninstalled and reinstalled. Cleared the caches for good measure.

But taxonomy terms still override my node type

ideas as to where I have gone wrong?

ex:
http://new.fafia-afai.org/en/news/withdraw_the_public_sector_equitable_c...

patched code:

 $type_trails = variable_get('menutrails_node_types', array());
    $href        = $type_trails[$node->type] ? $type_trails[$node->type] : FALSE;
    $term_trails = variable_get('menutrails_terms', array());
    if (!empty($node->taxonomy)) {
      foreach ($node->taxonomy as $term) {
        if (!empty($term_trails[$term->tid])) {
          $href = $term_trails[$term->tid]; 
jenpasch’s picture

Status: Reviewed & tested by the community » Needs review

(I am respectfully adjusting the status here. Hoping that its not user error...or actually that'd be fine too, if someone can point out the error of my ways)

grendzy’s picture

Status: Needs review » Reviewed & tested by the community

The patch is working for me.

jenpasch: Please see: #539922: Bug fix for taxonomy parent(s) overriding node type parent - $href is overwritten in menutrails_get_breadcrumbs Taxonomy terms override node types, by design.

jenpasch’s picture

oh man, really? I understood "Menu trails are evaluated in the order they are shown below" to mean that the top item (node type) took precedence over all others...thanks for clarification

hefox’s picture

jenpasch: Might be a useful idea to introduce a patch that weights the importance of parent items and decides the order items are evaluate. Or, re word that message. I don't need that, but it could be fairly simple.

(Current Patch works for me, thanks).

hefox’s picture

(Oh right I was going to say, could be useful performance wise, for nodes that have a lot of terms, to do an initial check with !empty(array_filter($term_trails)) to skip that foreach completely).

ayalon’s picture

FileSize
497 bytes

Today I had the the same problem. I debugged and finally come to the same solution as posted above. Unfortunately I did not search the forum before writing a patch :-)

This bug is really critical! Please commit this fix immediately, because all nodes that have taxonomy terms attached will fail with menu trails is a node type parent is defined.

jrabeemer’s picture

Confirmed #9 fixes menutrails from not working at all to responding as it should. RTBC!

Milkrow’s picture

Forgive me if I this comment doesn't belong on this thread, but I tried this patch and could not get it to work on Drupal 6.14 with MT 6.x-1.0 (I could not find a dev version of this module). I got an error on lines 132 and then 482 when I tried the patch above (the one with !empty, not isset). I'm not facing an issue with taxonomy, rather, I just can't see where "active" is added to the li...My content types are assigned to parent elements of the primary links, but active states do not appear unless the nodes parent menu is set to Primary. I've seen this work on another site, but for the life of me can't determine the issue. I'm not a PHP whiz...so kids gloves if you have them, please.

hefox’s picture

The dev version is accessible under Development Snapshots on the front page; my guess is the patch is against that but it's been too long.

eojthebrave’s picture

@Milkrow, can you confirm that the patch applied correctly.

This line

if (isset($term_trails[$term->tid])) {

in menutrails_node_location should have been changed to

if (!empty($term_trails[$term->tid])) {

If that change was made and you're still not seeing the "active" class I'm guessing the issue is on your theming layer. See this article for some discussion of possible issues with theme_* function implementations. #328517: Having menu highlighted when I visit individual nodes

Milkrow’s picture

That change was made (ostensibly, correctly). While I can see class="leaf active-trail" in a menu block (a menu I created) I cannot see the same class="leaf active-trail" in the Primary Links. I will read that other thread and see if that helps clear it up...but I'm only using Zen with CSS edits to theme...not making any major template changes.

Milkrow’s picture

Just a follow up here. I determined that the reason why the nodes weren't triggering "active-trail" is because they were part of a menu I created (not generated from childofprimary) and therefore those links were treated as external links and therefore will NOT trigger "active trail". Attributing those nodes to be a child of a primary link works. However, now I have to recreate new subnav menus using Menu Block (module). I hope this helps someone trying to figure this out.

ayalon’s picture

Can someone explain me, why this path isn't commited yet? I lost another 2 hours because of this buggy module.. More than providing a patch is not posible. And the patch was confirmed as a working solution

hefox’s picture

To my understanding, Sun is the active maintainer of this module and Sun is currently engaged in drupal 7 core issues, so is not as activally keeping up with 6.x modules as others would like (This statement based on comment/s in form module's issue queue; I do not Sun or anything ).

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status: Fixed » Closed (fixed)

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