Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Experimental project
This is a sandbox project, which contains experimental code for developer use only.
This module allows you to host and manage your content in Drupal, but embed it in any other page/website that allows JavaScript.
Here's how it works.
- Let's assume that your drupal site's URL is http://drupal.site/. Install and enable this module there. Create one or more pages of content there.
- You want to embed the above content in some other site. Let's assume there is a plain HTML page at http://some.other.site/host-page.html
- In host-page.html, include the following script tag anywhere
<script type="text/javascript" src="http://drupal.site/cms_embed/init"></script>
- Now you can have any number of container DIV's in your page that have a special attribute named "data-cms-embed". Like so ...
<div data-cms-embed="http://drupal.site/path/to/content">this will be replaced</div>
The content inside the DIV will be replaced with the content in http://drupal.site/path/to/content. Not just that, the extra stuff (header, footer, sidebars, blocks etc.) outside the content area will not be fetched. - If you want to further narrow down the parts of the content page that you want to embed, then you can provide an extra attribute named "data-cms-fragment" to the same DIV. Like so ...
<div data-cms-embed="http://drupal.site/path/to/content" data-cms-fragment="div#content div.something">this will be replaced</div>
Note that the value of "data-cms-fragment" is a jQuery selector.
You can see an example in sample.html file in this module.
Supporting organizations:
Development and Maintenance
Project information
- Created by Jitesh Doshi on , updated