I would like to use the [menupath-raw] in the pathauto module like [menupath-raw]/[title-raw] but [menupath-raw] contains the current node's menu title so there will be duplicated information in the url about current node: menuparent1/menuparent2/currentnodemenuitemtitle/currentnodetitle
I woult like to get in the url (after menu parent titles) one of the node's title or node's menu title.
e.g:
menuparent1/menuparent2/currentnodetitle
or
menuparent1/menuparent2/currentnodemenuitemtitle
I can't use only [menupath-raw] because nodes which doesn't have menu entry will not have path because [menupath-raw] returns nothing.
How can I create a token like [menupath-raw] without the last (current) item?
Or.. Any other solution welcomed.
Comment | File | Size | Author |
---|---|---|---|
#45 | menupath-parents.patch | 5.09 KB | modernaut |
#41 | menupath-parents.patch | 5.09 KB | modernaut |
#40 | menupath-parents.patch | 4.78 KB | modernaut |
#27 | 519834-27.patch | 4.66 KB | xjm |
#22 | token-519834-22.patch | 637 bytes | askibinski |
Comments
Comment #1
alisonsubscribing... would love to get help with this as well!!
Comment #2
svihel CreditAttribution: svihel commentedSubscribing
Comment #3
jweowu CreditAttribution: jweowu commented+1 for either some kind of [titleless-menupath-raw] token (so that we can use [titleless-menupath-raw][title-raw] -- the absence of a slash between the tokens is important for when there is no menu item), or else something like the following (which I have as a separate pathauto_titletoken.module, but would be much better if integrated into token_node.inc)
It might even be nice to have both tokens, because the title used when [menupath-raw] is populated could be different to the [title-raw] title.
Comment #4
peterjmag CreditAttribution: peterjmag commentedSubscribing, so I can link people with the same question to this issue. I also wrote a custom module to achieve the same thing, but jweowu's code in #3 is much more elegant. :)
Comment #5
jweowu CreditAttribution: jweowu commentedHere's a patch for token_node.inc to integrate [title-or-menupath] and [title-or-menupath-raw] (which is completely trivial, done this way).
peterjmag: Was there a particular reason you reverted the issue title and category? It's definitely a feature request, and the other title seemed rather more descriptive.
Comment #6
jweowu CreditAttribution: jweowu commentedComment #7
peterjmag CreditAttribution: peterjmag commentedjweowu: My apologies, I don't know how that happened!
Comment #8
jweowu CreditAttribution: jweowu commentedCross-linking to #640136: [menupath] / [menupath-raw] omits menu link title of new node in some circumstances in case it helps anyone.
There's an updated version of the module code from #3 in that issue.
Comment #9
ddanier CreditAttribution: ddanier commentedSubscribing
Comment #10
vadimk CreditAttribution: vadimk commented@jweowu - the code for [title-or-menupath-raw] above does not work when doing "Bulk generate aliases for nodes that are not aliased". $node->menu is not in $node in this case.
I modified it.
Comment #11
vadimk CreditAttribution: vadimk commented#5: token-519834-5.patch queued for re-testing.
Comment #12
vadimk CreditAttribution: vadimk commentedAutomatic alias is not taking into account the new menu title when updating the node. Really annoying. Seems like an issue with the pathauto module or the order of modules being executed. I fixed it by getting the menu link title from $_POST. Not sure if there is a better solution.
Comment #13
Poieo CreditAttribution: Poieo commentedSubscribing...
Comment #14
grendzy CreditAttribution: grendzy commentedsubscribing
Comment #15
arcaneadam CreditAttribution: arcaneadam commentedAny chance of getting this patch added to a new release? It works. I've been doing the exact same thing through an extra module forever. I'd say it's RTBC.
Comment #16
xjmTracking. I think I submitted a patch for this one back in 5.x... will test the current patch.
Comment #17
j-worker CreditAttribution: j-worker commented#5: token-519834-5.patch queued for re-testing.
Comment #19
xjmLooks like the patch needs to be re-rolled against the current dev branch.
Comment #20
gooddesignusa CreditAttribution: gooddesignusa commentedsubscribing
Comment #21
Dave ReidMarked #566326: Add support for menu path without the title as a duplicate of this issue.
Comment #22
askibinski CreditAttribution: askibinski commentedJust a quick patch against latest 1.x-dev which just replaces the existing menupath token output instead of introducing a new token.
Maybe not the most elegant solution, but probably what most people need.
Comment #23
jweowu CreditAttribution: jweowu commentedaskibinski: that can't actually be merged into the 1.x branch, though -- it would break the behaviour of existing sites.
Comment #24
KhaledBlah CreditAttribution: KhaledBlah commentedsubscribing
Comment #25
zmove CreditAttribution: zmove commented#22 don't seems to work (with pathauto). I cleared all the aliases, regenerated them, but [menupath-raw] continue to include the node title.
Comment #26
KhaledBlah CreditAttribution: KhaledBlah commentedFirst of all, thanks to all contributors!
I have edited the code from #3 and #10 according to my needs. Maybe this is useful to somebody else. The pathauto and the transliteration modules are needed for this.
My goal was:
comments welcome!
Comment #27
xjmReroll of #5 that actually applies.
Comment #28
xjmSee also #289630: Add [node-menu-parent-alias] token.
Comment #29
butler360 CreditAttribution: butler360 commentedThis is exactly what I've been looking for. Subscribing.
Comment #30
Dave ReidHow about we make this [node-menu-parent-path] so that it only uses the menu path of the node's parent menu item, so that way you're free to use [node-menu-parent-path]/[title] ?
Comment #31
butler360 CreditAttribution: butler360 commentedSounds fine to me as long as it accomplishes the same: just [title] if the node isn't part of a menu, and the entire menu path/title if it's part of a menu.
Comment #32
jweowu CreditAttribution: jweowu commentedWhich it wouldn't do, surely. You'd get /[title] instead of [title]
Comment #33
xjmHm. Seems like a double slash or a slash at the beginning of a URL alias is something our cleanup should fix.
I personally use the token in #289630: Add [node-menu-parent-alias] token because it accurately reflects the implied menu hierarchy even if I've customized the alias of a parent page. I just tested it and creating a page entitled "Moo Cows" that has no menu item gives the page the URL https://example.com/moo-cows. No double slash. I'm not sure if it's token, core, or pathauto that's fixing that, but it seems to work fine, so maybe we can call this a dup of #289630: Add [node-menu-parent-alias] token?
Edit: I can think of two other cases to consider:
content/[node-menu-parent-alias]/[title]
(is there a double slash in the middle?), orComment #34
Jackinloadup CreditAttribution: Jackinloadup commentedSubscribe. This is great! Thanks all!
Comment #35
dave_robinson CreditAttribution: dave_robinson commentedThe title values are the wrong way around in #27s patch
Should probably be
Comment #36
welly CreditAttribution: welly commentedIt seems that this patch doesn't clean the title if the token doesn't match a path so while a node that sits in a menu the url alias generated may be 'about-us/testing-title' - if this same node DOESN'T live in a menu, the alias generated becomes 'Testing title'. I'll try and fix the patch but if anyone gets to this before me, that would be great too!
Comment #37
ericbroder CreditAttribution: ericbroder commentedPatch #22 works for me when I run Pathauto. It fixes the problem "I can't use only [menupath-raw] because nodes which doesn't have menu entry will not have path because [menupath-raw] returns nothing."
Comment #23 may still be a valid point though. Other comments also seem to imply that patch #22 doesn't solve the problem.
I think comment #25 is a misunderstanding, the expected behavior of the patch is for [menupath-raw] to include the node title.
Comment #38
Dave ReidWhile patching #333590: Node menu token fails (node grants not saved yet, menu access checking, oh my!) I notice that the [bookpath] token excludes the current node title, but our [menupath] tokens do include it. So we have a fairly fundamental difference in functionality between the two tokens. The Pathauto-provided [catpath] also does include the current term in the path. :/
Comment #39
Dave ReidComment #40
modernaut CreditAttribution: modernaut commentedDave Reid had an excellent point in #30; My initial thoughts were on this as well.
I worked up a solution, and proposed two new tokens, [menupath-parents] and [menupath-parents-raw].
For example, you can place this text in your URL alias settings:
[menupath-parents-raw]/[title-raw]
And you should have the desired behavior in your URLs now.
Note:
At first, I created an exception to handle whether or not the '/' character should be provided at the end, which would handle some people's worries that [menupath-parents-raw]/[title-raw] would return /[title-raw] if no parent was present (i.e. you'd simply place [menupath-parents-raw][title-raw] in there, and the code will handle the rest). However, I noticed that there's already some error checking to remove any unwanted '/' characters.
Let me know if there's any issues with this..
Comment #41
modernaut CreditAttribution: modernaut commentedI've added some new changes to the patch to assess a thrown error when menupath values are strings..
I've built two sites thus far with these tokens - works like a charm for me.
Let me know how this looks to you.
Comment #42
modernaut CreditAttribution: modernaut commentedComment #43
jweowu CreditAttribution: jweowu commentedFixing invalid status change.
Comment #45
modernaut CreditAttribution: modernaut commentedLet's try this one..
Comment #46
Jackinloadup CreditAttribution: Jackinloadup commentedstarted testing
Comment #47
modernaut CreditAttribution: modernaut commentedI'm clearly not writing the patch correctly, although the code I'm trying to apply should work fine.. Maybe one of you guys could take a stab at it.
Comment #49
jweowu CreditAttribution: jweowu commentedInstructions for creating patches can be found under the Git instructions menu tab on the main page of every drupal.org project. Follow those, and you'll be fine.
Comment #50
modernaut CreditAttribution: modernaut commentedJust a note... With the new upgrade to the Token module ( 6.x-1.16 ), it looks like using [menu-link-parent-path-raw]/[title-raw] will achieve the behavior we're looking for.
Details can be found here:
http://drupal.org/node/289630
Nonetheless, please let me know if there's any issues with that method.
Comment #51
amitgarg CreditAttribution: amitgarg commentedHi,
put the below line in path & put your desire title
http://#
Thanks,
Amit Garg
amit@highpixel.in
http://highpixel.in
Comment #52
Anonymous (not verified) CreditAttribution: Anonymous commentedI can confirm that simply using [menu-link-parent-path-raw]/[title-raw] achieves the desired result
Comment #53
jweowu CreditAttribution: jweowu commentedmodernaut, jackocnr: how can a string with a hard-coded '/' in it achieve the desired result? (i.e. surely that approach breaks whenever [menu-link-parent-path-raw] is empty?)
Comment #54
Anonymous (not verified) CreditAttribution: Anonymous commentedNope - it works fine when [menu-link-parent-path-raw] is empty (i.e. there is no extra slash in the resulting URL). I couldn't tell you why tho - maybe pathauto automatically removes it, or maybe it's the fact that I have global redirect on, and that automatically removes redundant slashes?
Comment #55
Dave ReidComment #56
bluegeek9 CreditAttribution: bluegeek9 as a volunteer commented