I am trying to create sub tokens in a group off of existing Users token (sometimes referred to as "chaining"). So there are 2 parts to this. Creating the subgroup off the existing User tokens group and creating tokens within that group. I really only need the hook_token_info() part of this; not the actual token code.
I am trying to create a set of tokens of the form: [user:state:{token_id}]. Examples:
- [user:state:big]
- [user:state:small]
I am able to create [user:state-big] and [user:state-small] but would like to know how to have these grouped in the token browser under Users -> State.
From documentation linked to by Clive it would suggest this:
$types['state'] = array(
'name' => t('State'),
'description' => t('Tokens related to user state.'),
'needs-data' => 'user',
);
$tokens['user']['state']['big'] = array(
'name' => t('User State (Big)'),
'description' => t('The big state of the user.'),
'type' => 'user',
);
$tokens['user']['state']['small'] = array(
'name' => t('User State (Small)'),
'description' => t('The small state of the user.'),
'type' => 'user',
);
return array(
'types' => $types,
'tokens' => $tokens,
);
this code gives me these in the token browser:
State state Tokens related to user state.
and under Users:
[user:state]