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. In the same file add 'NodeEmbed' to Drupal.settings.cke_toolbar_DrupalFull and/or Drupal.settings.cke_toolbar_DrupalAdvanced arrays. For example:
    ['Link','Unlink','NodeEmbed','Anchor','LinkToNode', 'LinkToMenu'].
    For more information, see http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
  4. Download and install the iframedialog CKEditor plugin and place it in sites/all/modules/ckeditor/plugins
  5. Add the NodeEmbed icon to the correct toolbar in your CKEditor Editor Appearance settings.
  6. On the same page enable the NodeEmbed and iframedialog plugins
  7. Enable the 'Insert Node' input filter for your Text Format
  8. Enable the default view 'ckeditor-node-embed' (if its not already enabled). This view provides the content of the plugin dialog box.

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.

Using Node Embed and Media tags

The WYSIWG integration of Media breaks the Insert Node input filter and removes its content, because the Media tags are using a simular filter tag format as Node embed. To avoid problems you need to process the Insert Node input filter before the Convert Media tags to Markup input filter.

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!

waqarit’s picture

I have used same configuration options but got an error in wysiwyg. When I click "node embed" icon in wysiwyg toolbar, a dialogue box appears but it loads the whole site instead of nids. In console I got "Failed to load resource: ckeditor-node-embed Not found".
NOTE: I am using CKeditor library with wysiwyg module.

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.

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

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

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

amenity’s picture

Don't forget to enable the iframedialog plugin in the appropriate text format.

Ali.Geyik’s picture

Node Embed - CKEditor IFrame Dialog Field plugin Not found
Node embed requires the CKEditor IFrame Dialog Field plugin. Please download it from http://ckeditor.com/addon/iframedialog and extract it into /public_html/sites/all/libraries/ckeditor/plugins/iframedialog.

Receiving the above error on modules update, however my modules are not on /libraries sub but on /modules subdir. How to fix the false reference pls?

szeidler’s picture

It would recommend to use version 7.x-1.x-dev. The ckeditor integration is smoother and you only need to place the iframedialog addon into the libraries plugin folder.

Mats Svensson’s picture

"Enable the default view 'ckeditor-node-embed'.!

Ok...
How, where do i do that?

joseph.olstad’s picture

I've committed a patch by @weborion that fixes the integration with 'Media' , it should be ok now for those updating to the latest 'dev' of media 7.x-2.x or 7.x-3.x. I will tag a release at some point hopefully soon but not today.