Say if I need to dynamically insert some known node's content at place (table) on a [site page]? How could I do it?

Comments

kika’s picture

// load node
$node = node_load(array("id" => "111")); 

// print the node's title
print $node->title;

Also, you can use node_view($node) for displaying a node.
Optionally you can add more parameters to node_load(), it makes loading faster.
For example: node_load(array("id" => "111", "type" => "story"));

betarobot’s picture

Why do I get somth. like (sorry I'm not a bigguy in PHP yet):

Parse error: parse error, unexpected '<' in ... dp/modules/page.module(99) : eval()'d code on line 1

???

ax’s picture

you must not.

betarobot’s picture

here comes another err:

user error: Unknown column 'n.id' in 'where clause' query: SELECT n.*, u.uid, u.name FROM node n LEFT JOIN users u ON u.uid = n.uid WHERE n.id = '8' AND n.type = 'book' in ........../includes/database.mysql.inc on line 56.

now why?

ax’s picture

EOC = end of comment

betarobot’s picture

But still understand nothing.

I just need to post page (or book page) as this:

html table one cell of which will include whole content (body) of another node [different to node I post].

ok. I just loaded some node [node_load(array("nid" => "8"));], then how to print its content in html table trough php? What code do I have to post exactly?

Can someone be so kind to explain or give an example?

dries’s picture

You can print the node using $theme->node($node); where $theme is a global variable (you might have to global it depending on the current context/scope) and where $node is the object returned by node_load(). Example (not tested):

function mymodule_display_mynode() {
  global $theme;
  
  $node = node_load(array("nid" => 42));
   
  $theme->header();  // only if not called already
  $theme->node($node);
  $theme->footer();  // only if not called already
}
betarobot’s picture

betarobot’s picture

in iframe, but not the whole site, just node body.