The API Tokens module provides an input filter that allows to replace custom parametric tokens with rendered content. Each declared token binds to its handler function, that returns content, token will be replaced with. Token may contain parameters that will be passed to its handler function.

For example, you can declare a token which will render a current date on each page reload as follows:
  [api:date/],
or render blocks:
  [api:block["module", "delta"]/],
or even views:
  [api:view["view_name", "display_id"]/] - without arguments
  [api:view["view_name", "display_id", ["arg1", "arg2"]]/] - with arguments.

Each module is able to define its own parametric tokens and corresponding render functions. Module provides flexible caching mechanism.

Since API tokens accept parameters, it is highly advisable to add all required checks to your render functions to avoid performance impact and fatal errors.

Note that API Tokens module does not provide any visible functions to the user on its own, it just provides handling services for other modules.

Installation

Configuration

  • Go to /admin/config/content/formats and enable the API Tokens filter for any of your existing text formats or create a new one.
  • Declare some tokens and process functions (see api_tokens.api.php and api_tokens_example).
  • List of all registered tokens available at admin/config/content/api-tokens.

Credits

Current maintainers:


This project has been sponsored by:

  • Blink Reaction

    Blink Reaction is a leader in Enterprise Drupal Development, delivering robust, high-performance websites for dynamic companies. Through expertise in seamless integration, module customization, and application development, Blink creates scalable and flexible web solutions that provide the best in dynamic user experience. Specialties: Custom Drupal Development, Enterprise Drupal Development, Fortune 500 Clients, End to End Solutions.
  • Whole Foods Market

    America’s Healthiest Grocery Store™

    Who are we? Well, we seek out the finest natural and organic foods available, maintain the strictest quality standards in the industry, and have an unshakeable commitment to sustainable agriculture. Add to that the excitement and fun we bring to shopping for groceries, and you start to get a sense of what we’re all about. Oh yeah, we’re a mission-driven company too.

Project Information

Downloads