Avoiding duplicate book pages

m_freeman2004 - March 2, 2005 - 09:23

Hi,

I have two books and I need to publish the SAME article in BOTH of them. They are two distinct publications (newspapers actually) but somethimes they re-print articles from each other's publications.

Is there a way to publish the article in the first book and then just create a book page that links to the first one? I want to avoid duplicating content in the database.

Any ideas?

Marcus.

How to embed content from one node in another

mennonot - February 23, 2007 - 18:01

From http://drupal.org/node/57090#comment-192551

One way is to paste the following code into the body of your new node, with nid is the node id of the source. Make sure your input format is PHP.

<?php
echo node_view(node_load(nid));
?>

You may need to disable comment on the new node since comments should be placed on the source node.

This will mirror the content of the source node and avoid having to store the same information in your database twice.

How to grab just the body of the node

mennonot - February 24, 2007 - 01:41

After actually using this solution I discovered that it loaded the whole node including the title and "submitted by" info which duplicated information from the node I was embedding the content into, which wasn't was I was looking for. So I came up with this code which only embeds the body of the latest revision of the node:

<?php
$node_body
= db_fetch_array(db_query(SELECT r.body FROM node n INNER JOIN node_revisions r ON r.vid = n.vid WHERE n.nid =nid));
echo
$node_body[body];
?>

where nid (at the end of the query) is the id of the node you're taking the body from.

I know this is rough, so I'd welcome any feedback on how to clean it up and make it better.

Node's body

chelah - February 24, 2007 - 17:15

Try this:

<?php
$node
= node_load(nid);
echo
$node->body;
?>

To preview other elements of a node, try this:

<?php
echo '<pre>';
print_r(node_load(nid));
echo
'</pre>';
?>

 
 

Drupal is a registered trademark of Dries Buytaert.