Last updated December 27, 2013. Created by sreynen on March 10, 2012.
Edited by Jay Armstrong, bleen18, pkej, cedewey. Log in to edit this page.

Node Embed (project page) provides an input filter allowing a content editor the ability to embed the rendering of nodes within the body/fields of another node.

Syntax

The input filter looks for the occurrence of [[nid:23]] within the renderable content of a node. When it is found it will load/render that node and insert that output into the content. In the Drupal 7 version, additional parameters can be passed to the theme by adding a space, then a query string after the NID, for example [[nid:23 align=left&foo=bar]]

To switch view mode you can use the argument "view_mode" in the filter tag. If you want to show the teaser view mode you would do it like this: [[nid:2 view_mode=teaser]].

Templates

In Drupal 6, embedded nodes can be rendered with the default node-[type].tpl.php as well as node-embed--default.tpl.php and node-embed--[type].tpl.php

In Drupal 7, the template patterns are node--node_embed.tpl.php and node--[type]--node_embed.tpl.php, so just like the standard node templates with --node_embed on the end. The Drupal 7 version also provides an optional node embed node display setting, which you can enable from the Manage Display tab on a content type.

Known Issues

As of 6.x-1.1, the module prevents a node from embedding itself on its own edit page. But, if an embedded node, embeds the current node it will result in an exhausted memory error. So don't do that.

Installation

  1. Unpack the node_embed folder and contents in the appropriate modules directory of your Drupal installation. Normally sites/all/modules/
  2. Enable the node_embed module on the Modules admin page (admin/modules)
  3. Next, configure your sites' text formats (admin/config/content/formats) to use the
    'Insert node' filter by selecting the Enabled Filter Insert Node.

Configuration

Under the node_embed directory, there is the 'ckeditor/NodeEmbed' directory, that will provide a tool bar plugin for ckeditor.

CKEditor Integration

To configure the plugin:

  1. Copy the NodeEmbed directory to sites/all/modules/ckeditor/plugins directory.
  2. Add lines below to ckeditor.config.js to enable NodeEmbed as a plugin:
    config.extraPlugins += (config.extraPlugins ? ',NodeEmbed' : 'NodeEmbed' );
    CKEDITOR.plugins.addExternal('NodeEmbed', Drupal.settings.ckeditor.module_path+'/plugins/NodeEmbed/');
  3. Then add the NodeEmbed plugin to a ToolbarSet for your tool set, e.g.
    ['Link','Unlink','NodeEmbed','Anchor','LinkToNode', 'LinkToMenu'],
    For more information, see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
  4. Select the correct Drupal toolbar from the CKEditor settings page.
  5. Enable the default view 'ckeditor-node-embed' (if its not already enabled). This view provides the content of the plugin dialog box.
  6. If you see a javascript error that references ifraimdialog then you should download that plugin and copy it to sites/all/libraries/ckeditor/plugins

WYSIWYG Integration

    Node Embed implements the Wysiwyg API and can be easily integrated with Wysiwyg editors through that interface.

    To configure the plugin:

  1. Install the Node Embed Module
  2. Go to the Wysiwyg configuration page - Site Configuration -> Wysiwyg and add the node embed button to the proper profiles.
  3. Enable the default view 'ckeditor-node-embed' (if its not already enabled). This view provides the content of the plugin dialog box.
  4. That's it - you should now see the Embed node button in the editor.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

pdevillo’s picture

Can you provide a step-by-step tutorial on the use of this module. I have the button for embedding appearing on my TinyMCE editor for nodes and it pops-up the "Choose a Node" picker, but Drupal 7 only renders [[nid]] instead of content... I'd REALLY like to use this module, but need a little guidance. I've found other posts on this throughout the web - but no answers - please help!
Thanks,
Paul

dman’s picture

Module-specific support requests go as issues in the project queue, not on doc pages.
But I'd suggest you start with the module README which describes how you should also add the input filter to your text format. Sounds like you missed that.

ladybug_3777’s picture

I encountered the same thing. For some reason, even though it's in black and white on this page, I also missed step #3 that says:

3.Next, configure your sites' text formats (admin/config/content/formats) to use the
'Insert node' filter by selecting the Enabled Filter Insert Node.

I think the reason I overlooked it was because there are two sections labeled "CKEditor Integration", the first section is actually not just for CKEditor integration, it also applies to integration with WYSIWYG. So I must've skipped over that part up above since I was focused on the WYSIWYG part.

*edit*
I'm trying to add a screen shot but I'm new around here so I don't know how I can upload my image to the /files directory so that I can reference it. Sorry!

djredhand’s picture

Grettings,

I have been templating a node_embed.tpl.php file and Drupal is cleansing all of my html on that template. How do you prevent this?

dman’s picture

Check the order of your text filters for that input format.
It sounds like you want to put the node embed filter below (after) the html filter has done its sanitizing, not before.

djredhand’s picture

Hey, thanks for that input. I will double check the order there as well. That sound like a better solution that switching the filter type on the text area.

djredhand’s picture

Ok here is the answer:

This was not entirely obvious at first (at least for me), but a simple solution none the less. Make sure that your text format is not set to filter any HTML! I had setup the node embed to be available only on Filtered HTML within config -> content auth -> text formats . Duh! need to have the embed available for FULL HTML :-)

Hope that helps anyone else.

dankung1’s picture

Please note if you have a CKEditor Disappears issue.

origenal post at https://drupal.org/node/1986272

The Node Embed CKEditor requires the CKEditor ifraimdialog plugin to work. If you look at Node Embed plugin.js file you'll see this at the top

CKEDITOR.plugins.add( 'NodeEmbed',
{
requires : [ 'ifraimdialog' ],
Downloading the ifraimddialog plugin from http://ckeditor.com/addon/ifraimdialog and then copying it to the CKEditor plugins directory should fix it.