How can I replace a custom token? I am trying to add a custom token in pathauto.
I have a token [story-page-number].
Then in my hook_pathauto_alias_alter() I am trying to replace it using token_replace().  

Something is not quite right though.

token_replace("[story-page-number]", (array)node_load($context['data']['node']-&gt;nid));


Here's my custom token set up.

function mymodule_token_list($type = 'all') {
    $tokens['story-page-number'] = t('Page number (of story front)');
    return $tokens;
}

function mymodule_token_values($type, $object = NULL, $options = array()) {
    $values = array();
    $values['story-page-number'] = get_story_page_number($node-&gt;nid);;  

return $values;
}


What am I missing here, I thought it would be a lot more straight forward.
Try this:

$node = node_load($context['data']['node']-&gt;nid);
token_replace("[node:story-page-number]", array('node' =&gt; $node));


If $context['data']['node'] is already a node, then you may skip the node_load() call, and simply assign $node = $context['data']['node'];

Edit: Sorry, I didn't try your example in code.  You need to include the token type in your token names. In mymodule_tokens(), check to be sure that $type is 'node', and then look up $node from $data['node']. Note that you are using the Drupal 6 hook_token_values(); you should use the D7 hook_tokens().  Use the implementation of node_tokens() as a guide.

References


hook_tokens()
token_replace()