We've encountered several problems with the current token UI which uses the treeTable jQuery plugin:
- It is not accessible basically at all
- It is pretty bad performance-wise.
- It has to load all possible tokens in order to render it (and we're running into problems with recursive tokens).
- It would not be appropriate to move the current UI into Drupal core. It should be.

Once we get past Token 7.x-1.0 I want to seriously consider how we can improve this. Ideas:
- Use jQuery UI Accordion for the token type groupings rather than including them into the table - this should help improve performance since we're adding viewer rows that have to be processed.
- Use AJAX when a user wants to view nested tokens (get deeper in the token tree) - then we will only have to load the first level of tokens by default. Getting further will require relatively small request each time.

Comments

Dave Reid’s picture

Will be experimenting with http://jsfiddle.net/jGwKn/1/

Bojhan’s picture

subscribe

Noyz’s picture

subscribe

c4rl’s picture

[subscribe]

Some sort of autocomplete-driven browser seems like another possibility, but it could be inflexible and may not be appropriate for novice use since it requires needing to know some component of the machine name before typing.

Dave Reid’s picture

Dave Reid’s picture

Alan D.’s picture

We are going one step further, completely removing the themed tree and rendering these in a popup. While the server settings / resources are massively high, speed is an issue and this reduced the load time by about a 1 second. The token table by itself is 478KB.

7wonders’s picture

Is there anything that I can do in the meantime to fix unresponsive jquery issues when the token tree gets too big? I just installed the rpx/janrain engage module and it completely killed some pages with token options. Im assuming its related to this issue?

jhodgdon’s picture

Just a note that we are trying to get a token browser in core for Drupal 8 on this issue:
#514990: Add a UI for browsing tokens

zterry95’s picture

if there is some configaration to let us to decide which way we display the token list ( token_tree or token_tree_link),
it is will be great!

I am really experiecing a tough time to change all the token list to ajax by coding...

Thanks for your attention.

Sk8erPeter’s picture

@zterry95: I definitely favour the idea! Unfortunately by default, Token outputs huge nested tables without letting the administrator decide whether he/she wants to risk a memory exceeding: #1836264: Huge nested table trees displayed in field settings lead to "allowed memory size exhausted" errors - display should be AJAXified.
For some reason, unfortunately Dave Reid said he "just fundamentally disagrees" with changing Token's default behavior, and using Token tweaks instead: http://drupal.org/node/1842738#comment-6741198. I'm curious about the approach, but I didn't get an answer.

Elijah Lynn’s picture

Issue summary: View changes
Related issues: +#514990: Add a UI for browsing tokens
Elijah Lynn’s picture

This, this, this...

Use AJAX when a user wants to view nested tokens (get deeper in the token tree) - then we will only have to load the first level of tokens by default. Getting further will require relatively small request each time.

tkoleary’s picture

Use AJAX when a user wants to view nested tokens (get deeper in the token tree) - then we will only have to load the first level of tokens by default. Getting further will require relatively small request each time.

Sounds like this: https://www.drupal.org/project/hierarchical_select

alisonjo2786’s picture

Hi all, did you end up anywhere with this? I'm super grateful for the improvement in the token module whenever that was (couple years ago?) to switching to a token-browser-dialog instead of when the page with a form is rendered, but, it's extremely frustrating waiting for the token browser to load, and sometimes it simply doesn't work in some of my VMs -- I could go on, but I know I'm preaching to the choir :) Anyway, just curious if any of you got anywhere, even if just locally (or on some other related issue that simply didn't get linked to from this one), on this issue. Thank you!