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.
By edhel on
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
This is great, thanks. Much
This is great, thanks. Much better for my needs than the attached_node module.
Drupal 5 Node (filter)
Hi,
Can somebody please port this code to drupal 5.2?
Thanks in advance,
greetings,
Martijn
Just checked in a module
Just checked in a module that does this as a filter
Its called InsertNode
http://drupal.org/project/InsertNode
Hope it helps
This would be an ideal
This would be an ideal module if we could get it to work with 5.7
it appears not to be...
The module requires turning
The module requires turning on filter after installation.
See here:
http://drupal.org/node/253243#comment-849898