https://github.com/decipher/token_replace_ajax
https://www.drupal.org/project/token_replace_ajax
https://github.com/decipher/token_replace_ajax
Last synced: 12 months ago
JSON representation
https://www.drupal.org/project/token_replace_ajax
- Host: GitHub
- URL: https://github.com/decipher/token_replace_ajax
- Owner: Decipher
- Created: 2015-08-05T07:12:08.000Z (over 10 years ago)
- Default Branch: 8.x-1.x
- Last Pushed: 2023-12-15T08:49:19.000Z (over 2 years ago)
- Last Synced: 2025-02-14T09:57:29.609Z (about 1 year ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Token replace AJAX
[](https://travis-ci.org/Decipher/token_replace_ajax)
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.