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.
Spinning this off from the core issue so I can have other people follow and review the code.
Comment | File | Size | Author |
---|---|---|---|
#1 | arrow-right.png | 151 bytes | Dave Reid |
#1 | 738372-token-ui-tree-D7.patch | 13.4 KB | Dave Reid |
Comments
Comment #1
Dave ReidSummary:
Todos:
Improvements, comments, etc are completely welcome.
Comment #2
Dave ReidI've also uploaded this latest version to http://www.davereid.net/d7/examples/token
Comment #3
Dave ReidI've been in contact with the jQuery treeTable author as noted in the other issue and he's up for dual-licensing. I've made an official issue for the plugin at http://plugins.jquery.com/node/13634.
Comment #4
rfaySubscribing.
As far as usability, tokens stink in D7 without something like this. Completely unusable. Heretical as it is, it may be worth adding this feature to D7. Of course, those "in the know" will be able to use this from contrib.
Comment #5
arhak CreditAttribution: arhak commentedsub
Comment #6
eaton CreditAttribution: eaton commentedDave, one note is that D7 no longer has 'global' tokens. Every single token exists in a specific domain, even things like the current site name and slogan. So if someone wants the equivalent of the existing 'global' tokens, they would need to add 'current-date' and 'current-user' and 'site' to the list of token types to retrieve.
Also, to clarify -- I haven't had a chance to look too closely yet, but does the recursion limit affect all chaining? There are a lot of pretty useful tokens like [node:author:created:short] that would run into a 2-deep nesting limit.
Taking a look at the code now. Thanks!
Comment #7
Dave ReidI'd actually say that 'current-user', 'date' and 'site' are global tokens since they do not need data and will always work. The #global_tokens is just a TRUE/FALSE to include all possible global token types. User can easily put a FALSE value for that and manually specify the exact token values to be included in the tree.
The recusion limit is defaulted to 4 levels in the path. 2 was just a bad example, but it's over-ridable.
Comment #8
arhak CreditAttribution: arhak commented#7 +1 for #global_tokens the way you say (the same I thought when first saw it)
OTOH I would recommend a minimum of 5 level as a reasonable depth [comment:node:author:created:short]
Comment #9
Dave Reid@arhak: Technically the first part of the token doesn't count towards the recursion limit since it is only a type, and isn't a token that has chains, so that token is possible with a 4-depth limit. :)
Comment #10
arhak CreditAttribution: arhak commented@#8 thanks for clarification, then I'm ok with 4 (unless another token chain in core would be longer)
Comment #11
eaton CreditAttribution: eaton commentedDave, just to clarify -- is the reason for the depth limit because the entire tree gets pre-rendered? I've been kicking around the idea of an XML or JSON chunk describing all the token types and their relationships to each other (via the 'type' property) just being passed to the client side, and building the tree there to avoid the overhead. Would that be brutal, do you think?
Comment #12
Dave ReidYes its because the browser I worked up does it all ahead of time. There were other jQuery table/tree type plugins that supported fetching rows via AJAX and the idea was definitely intriguing. Most of the code I wrote should be able to be re-used for that approach. I'm also working on token auto-completion in Token.module as well.
Comment #13
eaton CreditAttribution: eaton commentedMakes sense. Eventually it would be cool to move to that sort of approach, but what you've posted above is also enough of a black box that the public interface to it wouldn't need to change if that approach were used down the line... I'd actually be thumbs-up on committing it to the D7 token branch as is, and treating it as something experimental. Token module in D7 could also form-alter the helper information into the spots in core that use tokens but don't fully explain them...
Comment #14
cubicphuse CreditAttribution: cubicphuse commentedHi, I'm Ludo van den Boom, the author of the jQuery treeTable plugin. Wanted to let you know that, as of release 2.3.0, the treeTable plugin is now dual-licensed MIT/GPLv2.
Comment #15
Dave Reid@cubicphuse: Woo-hoo! Welcome to the Drupal community and YOU ROCK!
Comment #16
Dave ReidI'll commit the current implementation to token D7 now.
Comment #17
gregglesNote that it must be GPLV2 and later to be included in Drupal's cvs repository.
Comment #18
Dave ReidCommitted the token UI browser to CVS!
Comment #19
Dave ReidMarking this issue as fixed since its been committed to 7.x and 6.x.