Hi,
I'm having some trouble having the advanced book block show up only in a specific book. I've tried using the "Show if the following PHP code returns TRUE " option using the following code

<?php
if (arg(0) == "node" && is_numeric(arg(1))) {
  if (30 == arg(1)) {
    return TRUE;
  }
  $result = db_fetch_object(db_query("SELECT parent FROM {book} WHERE nid = %d", arg(1)));
  if (30 == $result->parent) {
    return TRUE;
  } else {
    return FALSE;
  }
} else {
  return FALSE;
}
?>

It shows the block on main book page but the db query no longer works on it's children and its not designed wouldn't show up at all on the children of children.

Is there a better more elgant way in Drupal 6.x to detect if a page is a book and to use that to display the advanced book block?

Comments

antcw’s picture

If you are using taxonomy, you should be able to achieve this by using the configuration options given for a new book block. However, it only seems able to select a complete vocabulary. I have not been able to work out how to select just one term from a vocabulary.

PixelClever’s picture

Title: Place Advanced Book Block in a all pages on a specific book » Place Block in all children pages of a specific book
Project: Advanced Book Blocks » Drupal core
Version: 6.x-1.1 » 6.9
Component: Code » block.module
Status: Active » Closed (fixed)

This issue really isn't specific to the Advanced Taxonomy Blocks module and would be better suited to the general support forum. I am moving it to the blocks module queue.

I will say this much to give you an idea of why this isn't working for you. In Drupal 6 the table structure is a little bit wacky for the books, and in order to track down the true children of a book you have to query the menu_links table and find which mlids have the plid that matches the book's nid. You have to either have to combine that query with a join on the books table or do two separate queries to get the child nids from the mlids.

Like I said it's wacky but that's how it is in Drupal 6.