Token replace AJAX
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
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.
Â
