Since you're already writing custom code to handle it, I think it would be easier to define the token entirely in your own custom module and add a small admin interface that saves this price to a variable, rather than abusing the node system to fit your purpose.<div>
<br></div><div>funciton custommodule_token_list($type = 'all') {</div><div> if ($type == 'all' || $type == 'global') {</div><div> $tokens['price-foo'] = t('The price of foo.');</div>
<div> return $tokens;</div><div> }</div><div>}</div><div><br></div><div><meta charset="utf-8">function custommodule_token_values($type, $object = NULL, $options = array()) {</div><div> if ($type == 'global') {</div>
<div> $tokens['price-foo'] = check_plain(variable_get('price_foo', '$10.00'));</div><div> return $tokens;</div><div> }<br>}</div><div><div><br clear="all">Dave Reid<br><a href="mailto:dave@davereid.net">dave@davereid.net</a><br>
<br><br><div class="gmail_quote">On Tue, Feb 15, 2011 at 4:28 AM, DTH <span dir="ltr"><<a href="mailto:david@hartster.org">david@hartster.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Quick question: my original intention was to set it up so that people<br>
could use something like, for example, {{PRICE_OF_FOO}} in node<br>
content, so that when the price of foo changes, it only has to be<br>
changed in one place rather than in lots of different places.<br>
<br>
Rather than reinvent the wheel, I've used Token + Token Filter, so<br>
that people can use [token custom price-foo]. Everything works fine<br>
with:<br>
<br>
function custommodule_token_values($type, $object = NULL, $options = array()) {<br>
if ($type == 'custom') {<br>
$tokens['price-foo'] = "$19.99";<br>
return $tokens;<br>
}<br>
}<br>
<br>
The next step was to stick a UI on this so anybody can update the<br>
price. To do so I created a new content type "tokens", and added CCK<br>
fields for foo_price, foo_version_number etc. The code now looks like:<br>
<br>
function custommodule_get_tokens(){<br>
$node = new stdClass();<br>
$node->nid =12;<br>
$node->vid = db_result(db_query("SELECT vid FROM {node} WHERE nid =<br>
%d",$node->nid));<br>
$node->type = 'tokens';<br>
$content = content_storage('load', $node);<br>
return array("price-foo"=>$content['field_foo_price'][0]['value'],"version-foo"=>$content['field_foo_version_number'][0]['value']);<br>
}<br>
<br>
function custommodule_token_values($type, $object = NULL, $options = array()) {<br>
if ($type == 'custom') {<br>
$tokens = custommodule_get_tokens();<br>
return $tokens;<br>
}<br>
}<br>
<br>
Basically: is this the best way to do this, or is there a simpler/more<br>
native to giving users node tokens they can edit themselves. I wanted<br>
to check before I embarked on a round of clearing up the UI so that<br>
the "tokens" content type doesn't have all the menu/published/language<br>
stuff on etc, making sure people can't hit node/12 etc.<br>
</blockquote></div><br></div></div>