I post text of my quick hack-filter. Syntax:

[node:123] - insert full text (themed by theme('node'))
[node:123 body] - insert node's body
[node:123 teaser] - insert node's teaser
[node:123 link] - insert link to node
[node:123 collapsed] - insert collapsed node's body

Code (put it to file node_filter.module):


function node_filter_help($section) {
	switch($section) {
	    case 'admin/modules#description':
			return t('Filter for including node to body of another node by its ID.');
	}
}

function _node_filter_replacer($matches) {
	$node = node_load(array('nid'=>$matches[1]));
	switch ($matches[2]) {
	case 'body':
		return $node->body;
	case 'teaser':
		return $node->teaser;
	case 'link':
		return l($node->title, "node/$node->nid");
	case 'collapsed':
		return theme('fieldset', array('#collapsible'=>true, '#collapsed'=>true, '#title'=>$node->title, '#value'=>$node->body));
	default:
		return theme('node', $node);
	}
}

function node_filter_filter($op, $delta = 0, $format = -1, $text = '') {
	switch ($op) {
	case 'list':
		return array(0 => t('Include/link node by ID'));
    case 'description':
		return '';
    case 'prepare':
		return $text;
	case "process":
		$text = preg_replace_callback('/\[node:([0-9]+)(?:\s+(body|link|collapsed|teaser))?\]/', '_node_filter_replacer', $text);
		return $text;
	default:
		return $text;
	}
} 

Comments

Christefano-oldaccount’s picture

This is great, thanks. Much better for my needs than the attached_node module.

Summit’s picture

Hi,

Can somebody please port this code to drupal 5.2?

Thanks in advance,
greetings,
Martijn

markfoodyburton’s picture

Just checked in a module that does this as a filter
Its called InsertNode

http://drupal.org/project/InsertNode

Hope it helps

gost_gost’s picture

This would be an ideal module if we could get it to work with 5.7
it appears not to be...

gost_gost’s picture

The module requires turning on filter after installation.
See here:
http://drupal.org/node/253243#comment-849898