Closed (fixed)
Project:
Token
Version:
7.x-1.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
5 Apr 2012 at 05:26 UTC
Updated:
12 Jun 2015 at 14:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidComment #2
dave reidWith tests this time.
Comment #3
dave reidCommitted #2 to Git: http://drupalcode.org/project/token.git/commit/f306b40
Comment #5
Triskelion commentedI tried to use this capability with
Welcome [user:name]in a block title, and it simply returned the text.Had to add
global $user;to token_block_view_alter(), and change the call to token_replace to$block->title = token_replace($block->title, array( 'user' => $user ), array('sanitize' => FALSE));to get it to work.It is necessary to decide which tokens this function should support, and to pass the required $data array to token_replace().
Comment #6
dave reidYou should be using [current-user:name]. The token [user:name] only makes sense when provided with a specific user.
Comment #7
Triskelion commentedKudos! I have never had such a rapid response.
Point taken. However, if you are going to restrict the use to system tokens, it might be a good idea to add a token_tree element to the settings. The only list of tokens now available is at admin/help/token.
Token validation is not working because the #token_types array is empty, and
token_get_invalid_tokens_by_contextis bypassed (This might be a bug, since system tokens will never be validated if they are the only context permitted.).Great module, and thank you for the work you have done.
Comment #8
dave reidHrm, yeah it would be a bug if that validation is getting bypassed. It should still run for global token types.
Comment #9
dave reidPatch attached that ensure that if #token_types is set but to an empty array, it should still run token validation.
Comment #10
dave reidCommitted #9 to Git. http://drupalcode.org/project/token.git/commit/f9016e7
As for the token browser, I've been holding off adding the browser to new places due to the performance concerns of having the browser everywhere. Once we solve #1684984: Support opening token browser in a jQuery UI dialog on demand we'll be able to add the token browser into this.
Comment #11
Triskelion commentedThanks again Dave. I've started following the token browser issue.
Comment #12
jlongbottom commentedNode tokens do not seem to be working, but Current Page tokens do.
ex:
[node:title] - not working
[current-page:url:args:value:1] - working
Comment #13
dave reidAs expected. There's nothing currently that we do to determine what types of data we have in a reliable fashion to pass into token_replace() in this context aside from global non-context tokens like current-page.
Comment #15
kalabroVery cool! Could we make it more easy for site builders to see which tokens are supported?
Looks good with admin theme fix: #1859452: Dialog loads default theme CSS breaking admin theme
Comment #16
dave reid@kalabro: Can you please post this as a follow-up separate issue rather than re-opening an issue that's already been closed for half a year?
Comment #17
francescosciamanna commented#6 Solution works great for me!
[current-user:name] it's enough to do the job in the Block title!
Comment #20
dave reidComment #23
dave reid