Pass parameters with tokens Is it possible to send parameters along with tokens?

I have a module that defines the mod1_info and mod1_tokens.  If I enter %token:mod1:test on a page, it is replaced with &lt;a href='test.html'&gt;&lt;/a&gt;.

What I actually want is to enter %token:mod1:test[variable] and get &lt;a href='test.html'&gt;variable&lt;/a&gt;.

Is this possible?

Behind the scenes, the test.html is being built with a few dynamic parameters so it actually looks similar to test.html?param1=foo&amp;param2=bar.  What I need is a way for someone editing the site to insert a token on any page, and be able to specify what appears as the link (an image, some text, or both).
Using Drupal 7, modules can easily handle tokens similar to [node:author:name], where the part of the token after node:author is referring to a user token. Differently from the Token module for Drupal 6, the code that in Drupal 7 handles the tokens allows the creation of dynamic tokens. This is because on Drupal 7, modules implementing tokens can replace any token, not just the tokens they defined. The normal loop used in hook_tokens() is the following one.

foreach ($tokens as $name =&gt; $original) {
  // Check the value of $name, and generate the replacement that is assigned to
  // $replacements[$original].
}


Using the following code, you could get what you are trying to achieve. Tokens have a specific format, which is different from the one you are describing, though. The code has not been tested.

function mymodule_token_info() {
  $type = array(
    'name' =&gt; t('Anchors'), 
    'description' =&gt; t('Your description'), 
  );

  return array(
    'types' =&gt; array('anchor' =&gt; $type), 
  );
}

function mymodule_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  $sanitize = !empty($options['sanitize']);

  if ($type == 'anchor') {
    foreach ($tokens as $name =&gt; $original) {
      list($file, $title) = explode(':', $name);
      if (!empty($title) &amp;&amp; !empty($_GET[$title])) {
        $title = $_GET[$title];
      }
      else {
        $title = '';
      }

      $replacements[$original] = "&lt;a href='$file.html'&gt;$title&lt;/a&gt;";
    }
  }

  return $replacements;
}


The replacement for the tokens is so specific that I don't think you will find a module that does that. Your only possibility is a custom module you write.