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?

Comments

Sergii’s picture

Status: Active » Needs review
StatusFileSize
new527 bytes

This patch makes parents array consequentially indexed.

Status: Needs review » Needs work

The last submitted patch, token_menu_parents_1513500-1.patch, failed testing.

Sergii’s picture

Status: Needs work » Needs review
StatusFileSize
new548 bytes

The last one was wrong.

Status: Needs review » Needs work

The last submitted patch, token_menu_parents_1513500-2.patch, failed testing.

Sergii’s picture

StatusFileSize
new1.09 KB

It 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.

Sergii’s picture

Category: bug » feature
Status: Needs work » Needs review
Sergii’s picture

Title: Token [node:menu-link:parents] indexed by menu mlid » Be able to get value from array by its position
Sergii’s picture

StatusFileSize
new1.08 KB

Remove trailing whitespace.

miaoulafrite’s picture

you 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)

dave reid’s picture

Component: Token Actions » Code
jelo’s picture

Issue summary: View changes

This 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...

chris matthews’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev