Add new comment

Displaying content from one node in another

Submitted by kitt on Wed, 2005-05-11 21:22.

When writing custom drupal modules, I often want to include a blurb on the page about how to do a particular task on the page.

However, the phrases I use may not be the phrases or explanations another person would easily understand, given that I'm too close to the code.

The content of the blurb may change, too, as requirements change for the client.

Rather than hardcoding the text, making the client dependent on me for changes, I put the content into a node. In the custom module (e.g. the code I'm writing), I load the node and use the body of the node as the content to display.

  $node = node_load(array('nid' => '11363'));
  if (isset($node->body)) {
    $o .= $node->body;
  }

This has two requirements: the node exists, and the node has HTML included for formatting. Neither is typically a problem with the clients I have, but be sure to watch for the possibility the user is expecting filters to format the content before display.

Reply

The content of this field is kept private and will not be shown publicly.
Formatting guidelines : Expand filter description
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.