I have some code that I want shown only on child pages, not parent pages. Is there a code for that?

Comments

cog.rusty’s picture

Parent/child pages? You mean in a book structure? Or in a menu?

And where is your code? Inside the pages? In a theme template? In a block?

TurtleX’s picture

Yes, this is for book-type nodes. I'm trying to put the code in a template.

cog.rusty’s picture

Most book pages are parents and children of some other pages at the same time.

If by "not parent pages" you mean "not the top book page", then you can create a copy of node.tpl.php, name it node-book.tpl.php, edit it and put in it:

if ($node->book['depth'] > 1) {
  print $thestuff;
}

If by "not parent pages" you mean "not pages which have any children", then

if ($node->book['has_children'] = 0) {
  print $thestuff;
}
TurtleX’s picture

Unfortunately, none of those worked. I'm trying to add something to the left of the content in all book pages, except the top book page. I tried adding a block, but the content block gets added to the foot of the content and I need it to the left of the content (not in the left side bar though).

I'm running Drupal 5.22 .

cog.rusty’s picture

That code can work only after loading the $node that you want to check. In a node template it is probably already loaded, but in a block or in the content it isn't.

TurtleX’s picture

Thank-you for your help. I've just discovered PHP template regions and I've accomplished what I wanted by adding a custom region to my template. I added a block to that region and let Drupal's block filters handle everything.