This module provides tokens to embed Drupal Forge launch widgets directly into any website, allowing users to launch demos without first navigating to Drupal Forge.
Drupal Forge Token lets you embed Drupal Forge launchers in your Drupal site. Visitors can launch demos directly from your content without first visiting Drupal Forge. You can use tokens or Canvas components to embed launchers. You can also use raw HTML; Drupal and this module are not required for that option.
Although Drupal 7 has reached end of life, we continue to support the Drupal 7 releases of Drupal Forge Token so it can be enabled on Drupal.org. Follow the progress of enabling Drupal Forge tokens on Drupal.org in #3490328: Add token for Drupal Forge widgets.
Features
- Embed a launcher in formatted text, such as a content page or custom block, using Token Filter.
- Choose a launcher by its numeric Drupal Forge template ID.
- Optionally isolate the launcher’s styles from the surrounding page.
Post-installation
Use [drupalforge:71] wherever token replacement is supported to embed a launcher. Replace 71 with the numeric Drupal Forge template ID of the launcher you want to embed.
To isolate the launcher’s styles, use [drupalforge:71:isolate-styles] instead.
Find the template ID
- Open the Drupal Forge page for the demo you want to embed.
- Right-click the launcher and choose Inspect to open your browser’s developer tools.
- In the HTML inspector, find the enclosing
webform-componentelement and read itstemplateidattribute. For example, the Drupal CMS page usestemplateid="71".
Use that number in your token: templateid="71" becomes [drupalforge:71].
Embed with a Canvas component
Drag Drupal Forge launcher from the component library to your page. Enter the template ID in the settings pane and choose whether to isolate styles.
Embed with raw HTML
If you are not running Drupal or cannot install this module, paste the following code into an HTML page or an embed area that permits custom HTML and external scripts:
<webform-component
templateid="71"
relay-url="https://www.drupalforge.org/modules/contrib/embed_relay/relay.html">
</webform-component>
<script
src="https://www.drupalforge.org/modules/custom/starshot_core/assets/js/webform-component-embed.js"
defer="">
</script>
This example embeds the Drupal CMS launcher. Replace 71 with another numeric Drupal Forge template ID to embed a different launcher. Include the script once per page, even when embedding multiple launchers. Your website editor must preserve the custom element, its attributes, and the script tag.
Additional requirements
- Serve the page containing the launcher over HTTPS to support sign-in within the embedded launcher.
- If your site uses a Content Security Policy, configure it to allow the launcher’s scripts, styles, embedded frames, and network requests. For example, a policy restricting frames with the
frame-srcdirective:
Content-Security-Policy: frame-src 'self';would need to allow Drupal Forge:
Content-Security-Policy: frame-src 'self' https://www.drupalforge.org; - Visitors’ browsers must allow Drupal Forge to store and send cookies in the embedded context. Your site does not override visitors’ cookie or content-blocking settings.
Recommended modules
Token Filter lets you use launcher tokens in formatted text fields. To use launcher tokens in formatted text with Token Filter:
- Go to Configuration > Content authoring > Text formats and editors (
/admin/config/content/formats) and edit the text format used by your content. - Enable Replaces global and entity tokens with their values. In the filter processing order, place it after the other filters, especially Limit allowed HTML tags and correct faulty HTML, so the generated launcher markup is not removed. Save the text format.
If Token Filter must run before the HTML restriction filter, allow the webform-component element and its templateid, relay-url, and stylesheet attributes in that filter’s allowed HTML settings.
Supporting this module
Support Drupal Forge and the development and maintenance of this module through GitHub Sponsors or OpenCollective.
AI disclosure
AI-assisted tools were used during module development and to help prepare this project description. Maintainers review and are responsible for the project’s content and maintenance.
Ask your assistant about Drupal Forge Token
Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.