I found that the placeholder '?' in [node:menu-link:parents:value:?] token expects for menu link id.
I think this kind of behavior is useless because you must know actual parent's id. If you know the id, why just don't use needed parent's value?
Business case: I want to create pathauto pattern for some node content type, but I shun of too long links.
Therefore, I decide to format the pattern this way:
[node:menu-link:root:title]/[node:menu-link:parents:value:1]/[node:title]
But the problem is that [node:menu-link:parents:value:1] returns not second element of array, but looks for parent menu link with id '1'.
Are you sure that it is the right behavior? I mean, how often user needs to get title of parent menu link by known id and how often it might be needed to get the particular parent by its position?
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | token_menu_parents_1513500-4.patch | 1.08 KB | Sergii |
| #5 | token_menu_parents_1513500-3.patch | 1.09 KB | Sergii |
| #3 | token_menu_parents_1513500-2.patch | 548 bytes | Sergii |
| #1 | token_menu_parents_1513500-1.patch | 527 bytes | Sergii |
Comments
Comment #1
Sergii commentedThis patch makes parents array consequentially indexed.
Comment #3
Sergii commentedThe last one was wrong.
Comment #5
Sergii commentedIt seems that parents array should be indexed with ids to allow [node:menu-link:parents:keys] token.
So, maybe it's better to extend the functionality, not replace.
F.I. we could use # sign to mark the position, not id.
Comment #6
Sergii commentedComment #7
Sergii commentedComment #8
Sergii commentedRemove trailing whitespace.
Comment #9
miaoulafrite commentedyou can also get it using [node:menu-link:parent:parent:title] (note that parents are set twice, it then gets the second level in menu)
Comment #10
dave reidComment #11
jelo commentedThis is exactly what I am looking for. What is the desired solution now or is there no solution yet?
I am currently using [node:menu-link:parents:join-path], but that returns URL patterns that are way too long in some cases.
Instead of referencing the position like this [node:menu-link:parents:value:1] another option would be to limit the depth of [node:menu-link:parents:join-path], i.e. [node:menu-link:parents:join-path:2]. This could return the first two levels for parent links. This would allow for very flexible setups in my opinion.
I just don't know hot to code this unfortunately...
Comment #12
chris matthews commented