[menupath-raw] and [menu-raw] don't seem to work
mvuijlst - February 24, 2008 - 14:17
| Project: | Token |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | mikeryan |
| Status: | patch (code needs work) |
Description
When I set the default path pattern to
pathraw/[menupath-raw]/menuraw/[menu-raw]/titleraw/[title-raw]
and I create an "our history" page under home/company/about/, I get the following alias created:
pathraw/menuraw/titleraw/our-history
i.e. [menupath-raw] and [menu-raw] don't seem to work. Is this a pathauto issue or a token issue, or something else entirely?
This is with Pathauto 6.x-1.x-dev and Token 6.x-1.x-dev, both up to date.

#1
Reassigning to token - the problem is in token_node.inc, which references global $_menu (no longer there). The menu implementation has been totally reworked for Drupal 6, so this section of the code needs a rewrite. I'm taking a look now...
#2
Unfortunately, today's the last day I had a good chunk of time for development until after Drupalcon, and I didn't get to the point of producing a solution - I need to dig into the documentation a bit farther. I think it should be fairly easy to pull the necessary info out of the menu_links table.
#3
This is a huge problem, and makes Drupal 6 pretty much unusable for me.
#4
Would be great if we could use this feature in D6. I’ll be grateful!
#5
Any ETA on a fix for this?
I'm still too new to developing drupal modules to take a serious stab at coming up with a patch myself.
Thanks,
#6
Sorry, I was away for a few days, now I'm covering my day job while attending Drupalcon... The menu system was totally redesigned for Drupal 6, so this section of the token code needs to be completely written. I can probably throw together a quick patch tomorrow night (caveat emptor - many caveats) if people are desperate, but it'll take more time for me to get comfortable enough with the new menu system and test thoroughly enough to provide something releasable.
#7
That would work for me at this point.
We're evaluating drupal as a replacement CMS, i can't move forward until i can satisfy people that the URLs being auto-aliased is doable. I'm stuck between a rock and a hard place of "demonstrate that drupal works, or start writing an in house CMS"
a quick hack would do wonders to my work load :).
#8
OK, I've got a patch which also fixes the book token issue... Still more testing to do, but for the moment give it a shot...
#9
Works like a champ so far, limited testing.
Thanks.
#10
No joy with the patch here I'm afraid, although it did make some changes to the results.
Versions:
- Drupal 6.1
- Pathauto 6.x-1.x-dev
- Token 6.x-1.x-dev
- The above patch
Using [menupath-raw], it generates a path based on the first item in Primary Links even if the page is added at the same level. So, if "About Us" is the first in the list, the paths would be "about-us-0", "about-us-1" etc. for the other items regardless of depth. Adding /[title-raw] to it simply adds the page title to the path as expected. e.g. about-us-0/products even if Products is at the same level as About Us.
A related question, does [menupath-raw] include [title-raw] as I think it did in 5.7 or should the path be written [menupath-raw]/[title-raw] now? If the latter, that could cause problems with the top level of a menu.
#11
@imclean - I think including title-raw into menupath-raw was a short term bug in token that (hopefully) got fixed...
Updating status to reflect imclean's comments.
#12
Actually - perhaps this is a misunderstanding about title-raw being part of menupath-raw or not and the code is ready to go.
#13
I've attached an alternative patch similar to mikeryan's, but with a different method of deriving the menu path to address imclean's bug notes. It also exposes a new token - menu-link-title (and -raw) showing the menu link text.
I didn't include mikeryan's book token fix just to keep the patch easier to review.
#14
Thanks, I'll take a look at your approach. My goal is to commit a final patch for these two issues this weekend...
#15
Thanks for the informative responses. I've updated to the following versions:
- Drupal 6.2
- Pathauto 6.x-1.x-dev (2008-Apr-14)
- Token 6.x-1.x-dev (2008-Apr-09)
- sonnen's patch (post #13)
Everything is now working beautifully. I'll keep an eye on things but at this stage the above seems to do the business nicely.
#16
I've committed the last patch from http://drupal.org/node/223458 - I've let these issues lie too long, and it's at least a major improvement over the current state. It does not include sonnen's patch in #13 - @sonnen, can you reroll your patch against the current CVS?
Thanks.
#17
Here's the patch from post #13 above re-rolled against the current HEAD version. This incorporates the menu path fixes, and the new menu-link-title tokens.
Sorry for the delay on that. Thanks,
Richard
#18
greggles, the current dev version (2008-May-04) does include title-raw in menu-path-raw but otherwise appears to work fine. sonnen's patch in #17 obviously doesn't work with this version.
Edit: it seems there are still some problems with determining the correct path to the current page from the menu. In my case, a top level page includes the path of the first top and second level.
E.g.
Services is a top level menu item
- about - history
- about - history - services
#19
Hmm, with the new release without sonnen's patch nothing changed here. Using [menu-raw][title-raw] as pathauto-pattern, I still get only http:/ /mysite/[title-raw] aliases for new pages, no matter how deep the page is in the menu tree...
#20
FYI:
[menu-raw] and [menupath-raw] are also failing with the custom breadcrumb module
#21
I'm using menu breadcrumb module and experiencing this issue with the 2008-May-10 dev Token release. I guess that's not very helpful as you are just waiting for mikeryan to check sonnen's patch but anyway, hopefully better than "subscribe".
If someone rolls the patch against this version or say current CVS Head I should be able to test it.
#22
Here's sonnen's patch against the May version. However, I'm not sure it that's the intended way because the _menu_titles function is completely different and the patch just replaces it as a whole.
It does work for the pathauto module which is the only way I use it, so I can't say if it works for other scenarios, too.
#23
I think you forgot to attach the patch.
#24
Hmm, no I seem to have problems attaching files. Just saw that in another post, too. I upload and attach them but they just don't show :-( I'll try again.
Hah, ok, works now :-) Sorry for the delay!
#25
your attached "drupal_token.diff" patch is for the 2008-May-10 development release or for the official ?
#26
It's against the 2008-May-10 development release.
#27
The menupath-raw issue seems still to be there. Here is a patch against the 2008-jun-08 development release. It fixes for me all issues with menupath.
#28
Not sure whether this is a token issue with [menupath] or a pathauto issue, but posted it here because it replicates a problem documented above. If the mods feel that it's pathauto can it be moved across?
Installed:
Drupal Project (6.2 - 2008-Apr-09)
Pathauto Module (6.x-1.0 - 2008-Apr-30)
Token Module (6.x-1.x-dev - 2008-Jun-19)
Pathauto Settings (admin/build/path/pathauto):
Nodepath settings > Default path pattern: [menupath-raw]
Created content under 'Primary Links' and got the following menu structure and path aliases (also the pages were created in this order):
MENU URL ALIAS--------------------------------------------
My Bike my-bike
- Bike Wheels my-bike/bike-wheels
- My Bike Handlebars my-bike/my-bike-handlebars
My Truck my-bike/bike-wheels-0
- My Truck Cab my-bike/bike-wheels-1
See above - http://drupal.org/node/226074#comment-783188 - for similar experience.
Also, aliases were generated on page edit, not when created. I had to go back into the newly created node and resubmit the form to get url-aliases to generate. This seems to me to be more a pathauto issue.
Hope this is helpful. Happy to test patches if I know which ones to roll, against which releases.
#29
Thanks for the patch (#27). I rolled this one against the 6.x-1.x-dev 2008-Jun-19 release without errors. It solves my menupath issue with Autopath.
#30
Another issue would be if you said this pattern:
[menupath-raw]/[title-raw].htm
But, don't assign the node into a menu item, it creates a .htm and you get an error page. Obviously, because you didn't assign it to a menu item- but it should be smart enough to fail gracefully.
#31
@ghost25 - please define "fail gracefully".
@everyone_else - which patch do people agree is the best? Is it good enough to go in or does it need more work?
#32
Like, obviously as a developer I would know why that menupath pattern would fail- but there should be a small check within the function that happens if Automatic Alias is checked that would also see if Menu is defined for that node. I know its a little bit of a stretch, but for sites that have say a menu with sub menus, menupath is great for aliasing. But clients aren't always smart enough to add it into a menu.
#33
@gh0st25 - I still don't understand what "fail gracefully" means. Let's try this:
1. Node path pattern is [menupath-raw]/[title-raw].htm
2. User submits a node without any menu entry and with the title "something"
3. Pathauto will alias it as example.com/something.html
Expected results:
3. Pathauto should alias it as example.com/foo
I need you to fill in "foo" in step 3.
#34
About foo: Could pathauto warn the user via nodeapi/'validate' if the pattern contains menu parts and no menu entry was defined in the node edit form? The user could either define a menu entry or manually set an alias to get out of this.
About the patch: I'm only using token for pathauto, but for this the patch has been working flawlessly in the versions in posts #17, #24 and #27, so I vote for putting it into the CVS tree.
#35
May I take the opportunity to apologize Frank for not testing the patch you rolled as I said I would in #21. I got heavily involved in other work and also struggled to find a tool to apply patches under Windows!
#36
Has the latest patch been committed to the jun-29 -dev, or is this still just a patch?
#37
If something gets applied then we will update this issue and the status will change to "fixed".
The patch has obvious coding style issues (coder module will pick these out for you...). So, this patch won't be applied as is.
#38
subscribing