Closed (works as designed)
Project:
Token
Version:
4.7.x-1.4
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
23 Mar 2007 at 20:45 UTC
Updated:
14 Apr 2007 at 12:49 UTC
I set up a custom module to use the token hooks. Everything works great, until the page using tokens is edited. In the edit text box, the literal value is displayed and not the token. So on a save, the token is lost.
Any way to prevent this?
Im defining my tokens like this in my custom module:
function tcftokens_token_values($type, $object = NULL) {
switch($type) {
case 'global':
$values["Total One"] = variable_get('mytoken-total_one', 0);
$values["Total Two"] = variable_get('mytoken-total_two', 0);
Thanks.
Comments
Comment #1
emackn commentedI realize I left out "return $values" ..
I also call the tokens like this in my content:
The First Total is [Total One].
Comment #2
eaton commentedIt sounds like you're doing token_replace() when you SAVE your content, rather than when you VIEW your content. Is there a way to see a bit more context for this code?
Comment #3
emackn commentedAhh, thats probably the reason, I'm calling token_replace on $content inside page.tpl.php.
My first guess is that I need a conditional around the token_replace, but is there a more efficient way I should be using token_replace?
Thanks.
Comment #4
eaton commented