Using the latest panels I attempted to add a custom content pane, that rendered %node:created:raw, however, I kept getting a blank value.
This is my first time adventuring into anything related to ctools/tokens, but the problem seems related to the fact that ctools_context_entity_convert() calls token_info() to get a list of all valid tokens like so:
$tokens = token_info();
if (isset($tokens['tokens'][$token][$type])) {
$values = token_generate($token, array($type => $type), array($token => $context->data));
if (isset($values[$type])) {
return $values[$type];
}
}
However, token_info() only triggers hook_token_info, which in the case of nodes only returns the root tokens such as 'changed' and 'created', but not the nested date tokens for each such as 'changed:raw'. The nested date tokens are returned by calling hook_tokens(), which isn't called until token_generate().
So, due to the if condition, the function early outs thinking that there is no token 'created:raw'.
For now, I (perhaps naively) commented out the conditional:
if (isset($tokens['tokens'][$token][$type])) {
Which allows it to reach token_generate(), which allows the 'created:raw' token to be added by hook_token.
Does anyone have ideas on a proper patch for this?
Comments
Comment #1
jastraat CreditAttribution: jastraat commentedI am also interested in this. It will be even more important when the field tokens patch finally gets committed to the token module.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedI think it's probably safe to just remove that condition, actually.
I have done so and committed.