The Token replace AJAX module adds the ability to process individual tokens via an AJAX callback. It is primarily a developer utility, built for the purpose of offloading common functionality from other modules.
Usage
The Token replace AJAX module is essentially a very basic REST API with only one method:
token_replace/ajax/:token
Returns the token, replacement and any Drupal messages as a JSON object.
Parameters
-
:token
The token you wish to process in a standard token format.
Example: [node:title]
-
entity_type (optional)
An entity type to be used for the token data.
Example: node
-
entity_id (optional)
An entity id to be used for the token data.
Example: 1
-
key (optional)
An authorisation key for the Token being replaced, generated by the token_replace_ajax_access_key function.
Only required if the user does not have the appropriate permission (access token_replace_ajax callback).
Example Request
GET token_replace/ajax/[node:title]?entity_type=node&entity_id=1
Example Result
{
"token": "[node:title]",
"value": "Node 1",
"messages": {
"data": [],
"html": ""
}
}
Advanced usage
You can also POST an entity form to the endpoint (excluding the entity_type and entity_id parameters) and the module will create a dummy entity as the token data.
Project information
- Module categories: Developer Tools
- 43 sites report using this module
- Created by realityloop on , updated
- Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
Releases
Development version: 7.x-1.x-dev updated 5 Aug 2015 at 07:18 UTC