Webform Tokens
I'm working on the default template for Drupal Webform email submissions, and I realize that the built-in variables are not CCK tokens. The full list of variables isn't easily accessible, so I thought I'd post them here as a reference.
The following is a summary of internal tokens provided inside the webform.module source:
$tokens['basic'] = array(
'title' => t('Basic tokens'),
'tokens' => array(
'%username' => t('The name of the user if logged in. Blank for anonymous users.'),
'%useremail' => t('The e-mail address of the user if logged in. Blank for anonymous users.'),
'%ip_address' => t('The IP address of the user.'),
'%site' => t('The name of the site (i.e. %site_name)', array('%site_name' => variable_get('site_name', ''))),
'%date' => t('The current date, formatted according to the site settings.'),
),
);
$tokens['node'] = array(
'title' => t('Node tokens'),
'tokens' => array(
'%nid' => t('The node ID.'),
'%title' => t('The node title.'),
),
);
$tokens['special'] = array(
'title' => t('Special tokens'),
'tokens' => array(
'%profile[' . t('key') . ']' => t('Any user profile field or value, such as %profile[name] or %profile[profile_first_name]'),
'%get[' . t('key') . ']' => t('Tokens may be populated from the URL by creating URLs of the form http://example.com/my-form?foo=bar. Using the token %get[foo] would print "bar".'),
'%post[' . t('key') . ']' => t('Tokens may also be populated from POST values that are submitted by forms.'),
),
'description' => t('In addition to %get and %post, the following super tokens may be used, though only with logged-in users: %server, %cookie, and %request. For example %server[HTTP_USER_AGENT] or %session[id].'),
);
$tokens['email'] = array(
'title' => t('E-mail tokens'),
'tokens' => array(
'%email_values' => t('All included components in a hierarchical structure.'),
'%email[' . t('key') . '] ' => t('A formatted value and field label. Elements may be accessed such as %email[fieldset_a][key_b]. Do not include quotes.'),
'%submission_url' => t('The URL for viewing the completed submission.'),
),
);
$tokens['submission'] = array(
'title' => t('Submission tokens'),
'tokens' => array(
'%sid' => t('The unique submission ID.'),
'%value[key]' => t('A value without additional formatting. Elements may be accessed such as %value[fieldset_a][key_b]. Do not include quotes.'),
),
);
Here are the result of some of my tests:
- %title gives the page node title
- %site gives the domain title
- %server[HTTP_REFERER] gives the full URL (including protocol)
- %server[HTTP_SERVER_NAME] gives the URL string
- %get[q] gives the current page end path (eg. node/3409)
- %get[email] is equivalent to $site_email (which is the one I was looking for! This is not well known but I posted this around the community!)
This applies to the message header, and does not constitute a "To:" address on a reply from an email client like Outlook 2010. If you need this functionality, use the Webform Refply To module.