hi

I need to be able to create nodes that have inserted other nodes. In a similar way to what Panels do but I would need to do this with code in the Body field of the node. Ideally I would need to be able to insert a piece of code in the node.

any ideas? thanks

enrike

Comments

urrestieta’s picture

I found this snipset for drupal 4.7 in and old thread http://drupal.org/node/83349 but it does not work in drupal 5. Anyone knows what would be the equivalent nowadays?

// We save and restore the real path for the page
$q = $_GET['q'];
// Change event to the path you want, this is the part after q= (or after the base path if you have clean URLs enabled)
$_GET['q'] = 'event';
// Get and print the output for just the content associated with the path
// If you see the complete page within a page it means the path callback is probably calling theme('page', ....)
print menu_execute_active_handler();
// Restore the real path for the page
$_GET['q'] = $q;

I also found this in a similar thread

  print node_view(node_load(array('nid' => 2)), 1);

this one does exactly what i want but i would like to be able to pass aliases and not only node IDs
They both work by pasting the code into the BODY field and choosing PHP code as output format.

thanks for any tip

urrestieta’s picture

  $nodeid = explode('/', drupal_lookup_path('source', 'mycleanurl/blahblah'));
  print node_view(node_load(array('nid' => $nodeid[1])), 1);

insert this into the body field and select PHP code as output for the field.
$nodeid[1] is the number of the node.