If a node does not have a menu item, no token value is generated in menutrails_token_values(), which means that the token is empty for such nodes when used in pathauto.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

smithn.nc’s picture

Hi! I've patched my copy of menu trails, and I'm still running into the problem of nodes without menu items not getting a token. Menu trails is working otherwise; when viewing the node, the menu is active and the breadcrumbs are set.
Edit:
I've narrowed it down a little more. It seems that menu trails settings based on node types correctly generate tokens with your patch, while those based on taxonomy do not. I set menu trails to get the path based on node type, and the token worked. I then changed it back how I had it, with a taxonomy term setting menu trail. While breadcrumb and menu trail worked with the term based trail, the token didn't any more.

smithn.nc’s picture

Alright. I figured out what was going on... sort-of. In the function menutrails_node_location, terms are checked to be in the array $term_trails. It was failing because of the three terms, two were strings and one was an array. Then when menutrails_node_location tried to use $term->tid in a check, it wasn't applicable.

On another note, why is this the case? It doesn't make sense that some terms in $node->taxonomy would be arrays and others not.

Anyway, I rolled a patch including my change along with the original fix. If I've done something that doesn't make sense, please let me know, but it does fix things over here. Taxonomy based menu trails now give tokens as they should.

qbnflaco’s picture

I applied this patch and term pathauto still doesn't seem to work for me. Is there anything special I have to do after applying patch, deleting all content aliases and generating them again?

sun’s picture

Status: Needs review » Fixed

@smithn.nc: I think your addition to this patch is a different bug/issue. Please search the issue queue for already existing issues, and if there is none, feel free to create a new one. However, $term should always be an array, so I don't know whether that makes sense at all. Most probably a third-party contrib module is hi-jacking $node->taxonomy on your site.

Thanks for reporting, reviewing, and testing! Committed to 6.x.

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

brian_c’s picture

I had the same problem @smithn.nc was having; menutrails based on taxonomies weren't generating tokens for autopath.

I applied the patch to menutrails_node_location() from #2 and it fixed the problem for me as well.

Status: Fixed » Closed (fixed)

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

Daniel Wentsch’s picture

Hey there,

sorry for re-opening this old issue.
But I'm experiencing exactly this problem with both menutrails-6.x-1.1 stable and 6.x-1.x-dev (from Feb 28).
Nodes with menu entries get aliased as they should by the token [menu-trail-parents-path-raw].
For nodes without menu entries the token is just empty.
Is it possible that this old bug was re-introduced to the current versions of menutrails?

Regards,
Daniel

Edit: the code inside menutrails_token_values is almost the same as in the suggested patch and even when changing it to be excatly like in the patch it still doesn't work. So the problem must be somewhere else.

Sylvain_G’s picture

Subscribing (with menutrails 6.x-1.x dev fresh from today)