Drupal 6: get parent nid of a book child page

Submitted by fabio on Fri, 2008-06-27 18:07.

I had to get the parent nid of a book child page for a website which already uses Drupal 6.

Seems that the book module logic has changed deeply between version 5. The new stack implementation of the parent-child relationships is pretty complex, at least for me. I have to say that I did not studied it a lot thought.

So.. this is the code to do that:

<?php

if(isset($node->book)) { // book page
      $parent = book_link_load($node->book['plid']);
      $pid = $parent['nid'];
}

?>

Hope this helps.

Posted in:

Thanks

Submitted by digitalpbk (not verified) on Fri, 2010-07-30 06:13.

Just what I was searching for.

Thanks

Submitted by Paul (not verified) on Thu, 2010-07-29 04:44.

Thanks so much for posting this snippet - exactly what I needed today to sort out some custom breadcrumbs :)

Good help

Submitted by Sheshadri (not verified) on Wed, 2010-02-03 07:47.

Thanks for the help

regards,

This helped! Thanks.

Submitted by Quentin (not verified) on Sat, 2010-01-16 18:40.

This helped! Thanks.

thank you

Submitted by myselfhimself (not verified) on Sun, 2009-04-05 19:06.

thank you

Post new comment

The content of this field is kept private and will not be shown publicly.
If you have a personal or company website insert its address in the form http://www.example.com/ .
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <pre> <del> <img> <h2> <h3> <h4> <b> <video>
  • Lines and paragraphs break automatically.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
  • You may insert videos with [video:URL]

More information about formatting options