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.
I am debating creating an array token type in Token module which could then be extended by Pathauto to help provide the 'fake' URLs like menupath and catpath that we're currently missing from D6.
See #860082: BIKESHED: Token for a term or menu item's entire tree/hierarchy - I'm making this a major issue before 7.0 release of Pathauto and Token modules.
Comment | File | Size | Author |
---|---|---|---|
#48 | menutoken.zip | 1.15 KB | jelo |
#13 | 1046972-joined_path_token-d7-1.patch | 4.7 KB | redndahead |
#8 | 1046972-pathauto-array-join-path-token.patch | 4.69 KB | Dave Reid |
#4 | 1046972-pathauto-array-join-path-token.patch | 4.69 KB | Dave Reid |
#3 | 1046972-pathauto-array-join-path-token.patch | 4.67 KB | Dave Reid |
Comments
Comment #1
Dave ReidComment #2
Dave ReidComment #3
Dave ReidPatch attached for review.
Comment #4
Dave ReidComment #6
Dave Reid#4: 1046972-pathauto-array-join-path-token.patch queued for re-testing.
Comment #8
Dave ReidComment #9
Dave ReidCurrently the name of this token is [array:join-path]. What it does is take all the values in an array token, apply Pathauto clean-stringing to each value, and then joins the values together into a string with the '/' character. For example, given a [node:menu-link:parents:join-path] token and the node's menu link has the hierarchy of 'Root menu link' and then 'Parent menu link', the token would output as 'root-menu-link/parent-menu-link'.
Anyone have any other opinions on the name of this token (join-path)?
Comment #10
realityloopI'm wondering if joined-path my provide a better tense for this?
"what will this token return to me?" it returns a joined path..
"joined" alone would make sense to me too..
Comment #11
jenna.tollersonI like joined or joined-path. It is a little clearer, differentiates it from join:?
Comment #12
mallezieI also like joined. It's more clear than join.
Comment #13
redndahead CreditAttribution: redndahead commentedThis is a patch with the joined-path version
Comment #14
realityloopLooks good to me
Comment #15
acrollet CreditAttribution: acrollet commentedpatch in #13 works for me as well.
Comment #16
redndahead CreditAttribution: redndahead commented#13: 1046972-joined_path_token-d7-1.patch queued for re-testing.
Comment #17
SilviuChingaru CreditAttribution: SilviuChingaru commented#13 is working like a charm for me too... Thank you!
Comment #18
redndahead CreditAttribution: redndahead commentedFYI Dave Reid is leaning towards using the patch in #8. That patch works also. We just need to be patient for dave to get his focus back to this module only 2645 modules to get past first. ;)
Comment #19
AQ808 CreditAttribution: AQ808 commentedCan we just clone him instead?
Comment #20
SilviuChingaru CreditAttribution: SilviuChingaru commentedpatch #8 is working in more complex enviroment with taxonomy refs fields with multiple values. Waiting to see patch in dev at least.
Comment #21
RedTop CreditAttribution: RedTop commentedI've applied the patch in #8 but have no clue how to use it. Could someone tell me what token they used to get the menu path output?
Comment #22
redndahead CreditAttribution: redndahead commentedComment #23
RedTop CreditAttribution: RedTop commentedChecked the result of the patch a number of times but cannot find anything wrong with it. Still getting an error though. :/
using the following invalid tokens: [node:menu-link:parent:join-path].
Comment #24
redndahead CreditAttribution: redndahead commentedparents not parent
Comment #25
RedTop CreditAttribution: RedTop commentedSorry, posted the wrong attempt, tried that after parents did not work either.
Are you using the patch in #8 or #13?
edit: tried both patches, same result.
Comment #26
redndahead CreditAttribution: redndahead commentedI'm using #8 are you using the latest dev release also?
Comment #27
RedTop CreditAttribution: RedTop commentedI wasn't, now I am... didn't solve the issue though. I'll muddle through and may have to wait till a proper release.Edit: solved, needed to update token to latest dev as well. Sorry for wasting your time! Thanks. :)
Comment #28
Dave ReidFinally getting back to this. Everyone else pretty much prefers 'joined-path' even though Token module uses [array:join:join characters]?
Comment #29
realityloopI personally think that joined-path is more indicative of what gets returned.. but if you prefer join-path I'm more than happy to accept it, your the maintainer after all :)
I'd prefer to see this get committed rather than haggle over tense.
Comment #30
Dave ReidCommitted #8 with http://drupalcode.org/project/pathauto.git/commit/e09ab90. Thanks all for being patient with me.
Comment #31
drupalinside CreditAttribution: drupalinside commented#13 works for me only for nodes using [node:terms:join-path]
but i'd like to use also for taxonomy hierarchy, using [term:terms:join-path] nothing happens, so i tried to use [term:name] to check functionality and it works.
Where i'm failing?
there's something like to use something like " [terms:name:join-path]
thanks in advance
Comment #32
Dave Reid@drupalinside: [term:parents:join-path]
Comment #33
drupalinside CreditAttribution: drupalinside commentedthanks Dave, but i cant see "parentS" in token list, if i insert it manually got error message, tried stble version , patched stable version and dev version, there's something wrong i can't understand
regards
Comment #34
Dave ReidMake sure you are using Token 7.x-1.x-dev (the latest one) and clear your site's caches by running update.php quick.
Comment #35
drupalinside CreditAttribution: drupalinside commentedThank you Dave, got it
sorry for wasting your time
regards
Comment #36
ANDiTKO CreditAttribution: ANDiTKO commented#13: 1046972-joined_path_token-d7-1.patch queued for re-testing.
Comment #38
Dave ReidComment #39
ANDiTKO CreditAttribution: ANDiTKO commented#8: 1046972-pathauto-array-join-path-token.patch queued for re-testing.
Comment #40
ANDiTKO CreditAttribution: ANDiTKO commentedI cant apply any patch. I tried #8 and #13 but it wont do it.
Is this already ported to the latest pathauto 7.x-1.x-dev version?
Because i downloaded the latest 7.x-1.x-dev and i cant get the token to work.
Comment #41
MustangGB CreditAttribution: MustangGB commentedDave marked this as fixed so presumably either grab a git checkout or wait for it to filter through to dev release
Comment #42
acrollet CreditAttribution: acrollet commentedThis issue was committed here: http://drupalcode.org/project/pathauto.git/commit/e09ab90
The latest dev release contains this code.
Comment #43
acrollet CreditAttribution: acrollet commentedwhoops, wrong status.
Comment #44
Drupa1ish CreditAttribution: Drupa1ish commentedThis token is available only for taxonomy terms attached to node, with a single value. Is possible to provide also for taxonomy terms with unlimited cardinality? Thanks
Comment #45
jelo CreditAttribution: jelo commentedThis token is awesome. May I suggest a modification which I believe would be very simple and very useful. Right now the available tokens only allow to use the first parent, the last or all of them joined. However, it is not easily possible to create a structure to have /first-level/second-level/node-title or /first-level/second-level/third-level/node-title.
I am proposing to add a depth limitation to this existing token, e.g.
[node:menu-link:parents:join-path/depth]
I am not sure how to pass the depth into the token, but I think all it would need in the logic to create the token is a line like this before
$replacements[$original] = implode('/', $values);
if (isset($depth) && int($depth)) array_slice($values, 0, $depth);
What do you think?
Comment #46
Dave Reid@jelo I would recommend creating a custom token for that. I don't really have much interest in supporting too many advanced use cases. We're just trying to provide for the majority use case that needs tokens here in Token module, so I hope you will understand.
Comment #47
jelo CreditAttribution: jelo commented@Dave. Sure, I understand. I will check how to create my custom token for this.
Having said this, I would like to point out that my suggestion would eliminate a couple of tokens with a single one, i.e. it could cover already defined use cases plus additional ones all with less code.
[node:menu-link:parents:join-path/depth] could replace all of these tokens:
[node:menu-link:parents:join-path] => stays the same with no depth provided
[node:menu-link:parents:first] => [node:menu-link:parents:join-path/1]
[node:menu-link:parents:last] => [node:menu-link:parents:join-path/1:reversed]
While searching for a solution for "my" use case I came across a number of forum questions (e.g. on stackexchange, d.o etc.) for this particular use case, i.e. this might actually be a very common use case to create URL alias patterns like this /first-level/second-level/node-title
Cheers, J.
Comment #48
jelo CreditAttribution: jelo commented