Hi,
there is a problem getting the value "Book root from current node" for the content:nid especially in "add forms"(via entity reference or so). If the view is called within an "edit form" or on any content node (book chapter) everything works fine.

Comments

Zippy’s picture

Hi,
here is a qucik and dirty workaround.
The following code can be used inside the contextual filter. Select content:nid and for this value select "provide default value" -> choose "PHP Code". Insert the following code:

if(isset($_GET['parent']) AND is_numeric($_GET['parent']))
{      
  $parent = db_query("SELECT * FROM {book} WHERE mlid = :mlid", array(':mlid' => check_plain($_GET['parent']),))->fetchAssoc();
  return $parent['bid'];
}
elseif(isset($_GET['q']))
{
  $get = preg_replace("/[^0-9]/","",$_GET);
  $nid = (int) $get['q'];
  $nid = check_plain($nid);
  $node = node_load($nid);

  if (isset($node->book['bid']))
  {
    return $node->book['bid'];
  }
}