Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#49 | 226074_menupath_menu_fixups_49.patch | 4.36 KB | greggles |
#46 | 226074_menupath_menu_fixups_46.patch | 4.18 KB | greggles |
#44 | 226074_menupath_menu_fixups_44.patch | 2.51 KB | greggles |
#42 | 226074_menupath_menu_fixups_42.patch | 2.5 KB | greggles |
#39 | drupal_token.diff | 4.54 KB | Frank Steiner |
Comments
Comment #1
mikeryanReassigning 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...
Comment #2
mikeryanUnfortunately, 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.
Comment #3
aaronshaf CreditAttribution: aaronshaf commentedThis is a huge problem, and makes Drupal 6 pretty much unusable for me.
Comment #4
gerritvanaaken CreditAttribution: gerritvanaaken commentedWould be great if we could use this feature in D6. I’ll be grateful!
Comment #5
mbond CreditAttribution: mbond commentedAny 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,
Comment #6
mikeryanSorry, 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.
Comment #7
mbond CreditAttribution: mbond commentedThat 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 :).
Comment #8
mikeryanOK, 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...
Comment #9
mbond CreditAttribution: mbond commentedWorks like a champ so far, limited testing.
Thanks.
Comment #10
imclean CreditAttribution: imclean commentedNo 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.
Comment #11
greggles@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.
Comment #12
gregglesActually - perhaps this is a misunderstanding about title-raw being part of menupath-raw or not and the code is ready to go.
Comment #13
sonnen CreditAttribution: sonnen commentedI'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.
Comment #14
mikeryanThanks, I'll take a look at your approach. My goal is to commit a final patch for these two issues this weekend...
Comment #15
imclean CreditAttribution: imclean commentedThanks 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.
Comment #16
mikeryanI'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.
Comment #17
sonnen CreditAttribution: sonnen commentedHere'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
Comment #18
imclean CreditAttribution: imclean commentedgreggles, 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
Comment #19
Frank Steiner CreditAttribution: Frank Steiner commentedHmm, 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...
Comment #20
mikeque CreditAttribution: mikeque commentedFYI:
[menu-raw] and [menupath-raw] are also failing with the custom breadcrumb module
Comment #21
fletchgqc CreditAttribution: fletchgqc commentedI'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.
Comment #22
Frank Steiner CreditAttribution: Frank Steiner commentedHere'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.
Comment #23
fletchgqc CreditAttribution: fletchgqc commentedI think you forgot to attach the patch.
Comment #24
Frank Steiner CreditAttribution: Frank Steiner commentedHmm, 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!
Comment #25
rbishop CreditAttribution: rbishop commentedyour attached "drupal_token.diff" patch is for the 2008-May-10 development release or for the official ?
Comment #26
Frank Steiner CreditAttribution: Frank Steiner commentedIt's against the 2008-May-10 development release.
Comment #27
alexknaub CreditAttribution: alexknaub commentedThe 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.
Comment #28
baronmunchowsen CreditAttribution: baronmunchowsen commentedNot 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):
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.
Comment #29
ar-jan CreditAttribution: ar-jan commentedThanks 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.
Comment #30
kevinquillen CreditAttribution: kevinquillen commentedAnother 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.
Comment #31
greggles@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?
Comment #32
kevinquillen CreditAttribution: kevinquillen commentedLike, 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.
Comment #33
greggles@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.
Comment #34
Frank Steiner CreditAttribution: Frank Steiner commentedAbout 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.
Comment #35
fletchgqc CreditAttribution: fletchgqc commentedMay 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!
Comment #36
ar-jan CreditAttribution: ar-jan commentedHas the latest patch been committed to the jun-29 -dev, or is this still just a patch?
Comment #37
gregglesIf 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.
Comment #38
bforchhammer CreditAttribution: bforchhammer commentedsubscribing
Comment #39
Frank Steiner CreditAttribution: Frank Steiner commentedHere's a new version against 6.x-1.x-dev (2008-Jun-29), re-adding the menu-link-title[-raw] tokens that got lost in alexknaubs version, and validated with the coder module.
Comment #40
alf nif CreditAttribution: alf nif commented#39 thanks!! This patch works great!
Comment #41
gregglesI'm reviewing this now b/c I'd like to do a new 6.x release soon and like for this to be in it.
Can you clarify the need for "menu-link-title" ? Isn't that the same as "menu" ?
Comment #42
gregglesHere is what I found in 5.x for comparison purposes:
1. Created a node where the menu item is called "some title" and it is in the primary links.
menupath: some title
menu: Primary links
2. Create a second node with the menu item called "another title" that is a child of "some title" created in step 1
menupath: some title/another title
menu: Primary links
So, I now see the motivation to add the new feature of "menu-link-title" which provides the last piece of the menupath (e.g. in my second step menu-link-title would be "another title").
One other thing I have noticed is that $node->menu is only available in the $node object when a node is being saved. If you get a node from node_load then you do not have that information. So...I'm working on getting the information in a different and somewhat more reliable method. The trade off of my method is that if the menu is in the process of being changed AND the module getting the tokens is getting it from some point before the menu module has saved the data then my method will show what the menu USED to be...
I'm more interested in getting the data consistently even when we aren't on a node insert than I am in getting it right before the node is inserted.
So, I've changed the patch around a little bit and left it so that the book tokens are still working (i.e. I removed the changes to _menu_titles()).
I also made sure that menupath is consistent with the 5.x behavior (which is to say that it returns all elements in the menupath including the current element).
Comment #43
Frank Steiner CreditAttribution: Frank Steiner commentedAfter upgrading to the dev version from 2008-Jul-18 and applying this patch, I get
Fatal error: Call to undefined function dsm() in /usr/share/drupal/modules/token/token_node.inc on line 76
for every page I create. The page is there afterwards, but not even th user who created it can access it. So I guess sth. is wrong :-)
Comment #44
gregglesGood point. If you delete that line it should work fine (or use the attached...).
Comment #45
Frank Steiner CreditAttribution: Frank Steiner commentedHmm, I end up with
You are using the token [menu-link-title-raw] which is not valid within the scope of tokens where you are using it.
now when I'm using it in the path for my pages, and indeed it doesn't show up in the list of valid replacement patterns, although it really is in token_node.inc and I even disabled and re-enabled pathauto and token :-(Comment #46
gregglesThanks for your continued bug testing/reviews Frank Steiner!
I've attached an updated patch which removes some pointless comments and needless newlines and then adds in the descriptions to the node_token_list which is what was making Pathauto confused.
Can you try one more time?
Comment #47
Frank Steiner CreditAttribution: Frank Steiner commentedSeems to work fine!
Compared to the former patches it has changed in that menupath-raw includes menu-link-title now. Before, menupath-raw was missing it, so one had to use
[menupath-raw]/[menu-link-title-raw]
to get the full path. I guess that is indented? I'm not sure if there is a situation where having all but the last element of the menu path would make sense, so for me it is fine this way.Thanks!
Comment #48
Frank Steiner CreditAttribution: Frank Steiner commentedThere is still a little issue with [menu-link-title-raw]: If that appears in the pattern, e.g. like
[menupath-raw]/[menu-link-title-raw]
and you create a page without a menu entry, pathauto will consider [menu-link-title-raw] (and only it, not [menupath-raw]) a string and not a pattern and create the alias "[menu-link-title-raw]" for the node.Comment #49
gregglesre #47 - I made that change to be more in-line with the way that these tokens worked in Drupal5 (at least I think so).
re #48 - fixed in attached.
Thanks again for the reviews. I think we're finally getting there.
Comment #50
damjan.cvetan CreditAttribution: damjan.cvetan commentedHello.
I've just patched the token_node.inc file with #49 patch and it looks just fine for me. Tnx
Comment #51
Frank Steiner CreditAttribution: Frank Steiner commentedLooks fine!
Comment #52
gregglesAnd committed to 6.x.
Thanks again Frank Steiner and everyone for your help with patches and reviews.
Comment #53
dascope CreditAttribution: dascope commentedawesome, thank you!
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #55
Renee S CreditAttribution: Renee S commentedHmm, I'm getting this problem with the most recent dev release. ??
Comment #56
DjC4 CreditAttribution: DjC4 commentedI'm still having this problem in D6.9 with the latest build of Token. Installed from Acquia.
Is anyone else? Am I doing something wrong?
Comment #57
DjC4 CreditAttribution: DjC4 commentedChanged Status
Comment #58
Frank Steiner CreditAttribution: Frank Steiner commentedIt's only fixed in -dev, not in 1.11
Comment #59
DjC4 CreditAttribution: DjC4 commentedOoops! My apologies. I will download the dev version and begin testing it.
Thanks for the heads up Frank, I missed that. It looked like it got committed, but I read it wrong.
Sorry, I'm new here :P:P
Comment #60
fletchgqc CreditAttribution: fletchgqc commentedI guess we'd better change the status back.
Comment #61
temp CreditAttribution: temp commentedSory but i open this thread another time.
some problem of token module witch link of int_meta module, we try solve this in this thread http://drupal.org/node/391328
i try witch 6.x-1.x-dev - and no changes.
Comment #62
temp CreditAttribution: temp commentedComment #63
Renee S CreditAttribution: Renee S commentedI'm using the latest of each, both pathauto and token, and I'm still getting this problem. It doesn't work if the content is part of a book. I want my menu aliases to follow the menu and then the book... !
Comment #64
temp CreditAttribution: temp commentedyes, i'm too, i use latest token dev relise and http://drupal.org/project/int_meta, token for menu dont work.
stay witch problem from #61.
Comment #65
kevinquillen CreditAttribution: kevinquillen commentedYes, I can confirm it does not work. It seems to get the menu trail but no title.
Example, using menupath-raw on a content type of Event
I place the new node in Events > Festival
When I save, pathauto creates an alias of events/festival.htm.
If I try again, I get events/festival.htm-0, and so on, and so forth.
Comment #66
kevinquillen CreditAttribution: kevinquillen commentedIs it because menu_get_all_data is getting ONLY nodes that are status = 1? We just notcied that when dealing with unpublished nodes.
Comment #67
PeteS CreditAttribution: PeteS commentedTo clarify, what we're seeing is that, in the _menu_titles() function in token_node.inc, the code loops through data from the D6 function menu_tree_all_data(). But menu_tree_all_data() seems to filter out unpublished nodes no matter what (status = 1), which means that token can't see unpublished nodes for the purposes of menupath/menupath-raw. Sooo... am I mistaken, or should token_node.inc not be relying on a function that strips out unpublished nodes?
Comment #68
kevinquillen CreditAttribution: kevinquillen commentedHello? Bueller?
Comment #69
gregglesThis was the original issue on this topic. New issues about menu tokens not working in certain circumstances should be new issues.
Also, patches welcome.
Comment #70
benorgan CreditAttribution: benorgan commented#67 you are right, changing this in includes/menu.inc makes the token / pathauto work as expected but I don't really think changing core code is a valid solution.
Can this be reopened and fixed or is there a new active issue for this problem?
Comment #71
gregglesComment #72
benorgan CreditAttribution: benorgan commentedNew issue: http://drupal.org/node/339211