Extending from #860082: BIKESHED: Token for a term or menu item's entire tree/hierarchy we should provide [term:parents] and [menu-link:parents] tokens which are an array of the parents of the respective term or menu link starting at the root as the first element value, and the immediate parent as the last array value (e.g. array('Root', 'First sub-term', 'Term parent')
). Together with an [array:pathauto] token that joins the array values with '/' after applying its string cleaning to each value, we can now fully implement our [termpath], [catpath] and [menupath] tokens as [term:parents:pathauto].
Comment | File | Size | Author |
---|---|---|---|
#27 | 1266928-parents-array.patch | 9.75 KB | Dave Reid |
#19 | 1266928-d7-3.patch | 4.48 KB | redndahead |
#19 | 1266928-d7-4.patch | 4.96 KB | redndahead |
#18 | 1266928-d7-2.patch | 6.82 KB | redndahead |
#17 | 1266928-d7-1.patch | 6.34 KB | redndahead |
Comments
Comment #1
MustangGB CreditAttribution: MustangGB commented+1 and subscribing
Comment #2
rp7 CreditAttribution: rp7 commentedsubscribing
Comment #3
Dave ReidInitial patch.
Todo:
- Documentation
- Tests
Comment #4
Dave ReidComment #5
brant CreditAttribution: brant commentedsubscribe
Comment #6
Fabianx CreditAttribution: Fabianx commentedsubscribe
Comment #7
fenstratsubscribe
Comment #8
acbramley CreditAttribution: acbramley commentedsub. Patch failed on latest dev release, only the info file though.
Comment #9
acbramley CreditAttribution: acbramley commentedTested [node:menu-link:parents:join:?] not too sure where the "join" character is meant to go (I assume it should replace the question mark? If so, it didn't work for me.
Comment #10
acbramley CreditAttribution: acbramley commentedAh I got it [node:menu-link:parents:join:/] gave me an imploded url of parent menu items. I had to change punctuation settings to not remove slashes though, this means that slashes in node titles wouldn't be removed though but this should be fine.
Comment #11
acrollet CreditAttribution: acrollet commentedpatch in #4 applies cleanly to latest 7.x-1.x, taxonomy parents token works great, thanks much!
Comment #12
abaddon CreditAttribution: abaddon commentedsubscribe
Comment #13
dtrdewaele CreditAttribution: dtrdewaele commentedOn what version do you apply the patch? Tried it on beta6 and dev release but both give errors. Tokens are available, but as soon as I bulk update my aliases, I get errors (deleted aliases first).
Comment #14
sense-designPlease apply #4 to your token module, then take this patch to patch the "token.tokens.inc", continue with #10 after that.
Comment #15
sense-designPlease ignore #14
Please apply #4 to your token module, then take this patch to patch the "token.tokens.inc", continue with #10 after that. This is the correct patch.
Comment #16
wojtha CreditAttribution: wojtha commented@sense-design I tried the patch from #15, but when I tried apply it I got:
So I applied the patch manually. Now when I look at diff I see the only change:
The other hunks from your patch #15 seems to be included in the previous patch #4 by Dave Reid. Is it correct? Or am I missed/overlooked something?
Anyway menu parents token seems to be working as expected.
Comment #17
redndahead CreditAttribution: redndahead commentedHere is a re-roll of #4
Comment #18
redndahead CreditAttribution: redndahead commentedThis is #15 rerolled and it seems wojtha is right about the only change. @sense-design can you explain why you added that piece?
Comment #19
redndahead CreditAttribution: redndahead commentedPer davereid in irc the token.inc portion shouldn't be there.
#3 is #17 patch without token.inc
#4 is #18 patch without token.inc
Comment #20
Dave ReidYeah the addition in #15 should also be ignored. It will not work.
Comment #21
redndahead CreditAttribution: redndahead commentedLooks like it passed. So 1266928-d7-3.patch should be the correct patch to use. Anyone care to RTBC?
Comment #22
Dave ReidWe still need additional tests to confirm all these tokens are working as expected and in the correct order.
Comment #23
redndahead CreditAttribution: redndahead commentedI'm having a difficult time trying to figure out the tests. Any chance of getting an example of the taxonomy parents test and then I can maybe figure out the menu one from there?
Comment #24
mjcarter CreditAttribution: mjcarter commentedI just tried this out, parents token showed up in replacement patterns with no problems, but trying to generate aliases I got:
Fatal error: Class 'MenuTokenObject' not found in C:\xampp\htdocs\website\sites\all\modules\token\token.module on line 936
This is using the beta 7 release, should I be using the dev version?
Edit: Tried the dev release:
Fatal error: Class 'MenuTokenObject' not found in C:\xampp\htdocs\website\sites\all\modules\token\token.module on line 936
Line 936 is $cache[$mlid] = array($plid => new MenuTokenObject($parent)) + $cache[$mlid];
I tried both patch d7-3 and d7-4 and get the same error with both.
Comment #25
redndahead CreditAttribution: redndahead commentedIt seems the token.inc file that was removed from this patch contained the MenuTokenObject class. @davereid is there another patch somewhere that needs to get pushed forward so token.inc can be added?
Comment #26
Dave ReidAdding blocker tag.
Comment #27
Dave ReidHere is the version without needing the objects which should have been left for #1195874: Need to figure out how to create nested tokens from the array token type and not been merged into this issue. This also includes additional tests to ensure the tokens work properly.
Comment #28
Dave ReidThis passed the bot and locally for me, so committed #27 to Git. Thanks all!
http://drupalcode.org/project/token.git/commit/c4e5564
Comment #29
redndahead CreditAttribution: redndahead commentedSorry I didn't get to it in time. Thanks for committing quickly.
Comment #30
Dave ReidComment #32
tahiticlic CreditAttribution: tahiticlic commentedHi,
this is quite good, but doesn't mimic completely the behavior of termpath token seen on D6. Especially, there's no more "/" separator between terms, and this "/" is replaced by a "-" : is there a way to avoid this?
I mean, on D6 you were able to mix "-" (in the term) and "/" (between terms).
Comment #33
tahiticlic CreditAttribution: tahiticlic commentedComment #34
Dave ReidPlease see #1046972: Provide an [array:join-path] token