Book menus do not expand

geilhufe - May 7, 2008 - 03:09
Project:Active menus
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

I have book menus on my site inside the block provided by the book menu. Active menus works fine on the main navigation menu, but fails on the book menus. Active Menus basically hangs looking for the links.

#1

nedjo - May 7, 2008 - 03:17

David, good to hear from albeit through the issue queue.

Looks like I forgot to test with book (which was extensively rewritten for 6.x).

Quick fix: delete modules/book.inc.

I'll have a look at a fix when I get a chance.

#2

berenErchamion - June 8, 2008 - 21:56

I'm having the same problem. Great module - adding the book support would be super cool.

#3

korvus - June 18, 2008 - 15:57

For the record, I am pretty new to Drupal modules and very new to Drupal 6 modules.

With that out of the way, I believe modifying modules/book.inc to replace the existing activemenu_js_book() function with this one makes activemenu work for books (I only have one book on my site, so I've only tested it under the most basic of circumstances).

<?php
function activemenu_js_book() {
  if (
$path = activemenu_get_request_path()) {
   
// The book menu will use the nid as the key, so we take the second part of the path which will be the nid.
   
$arg = explode('/', $path);
   
$nid = $arg[1];
   
//print drupal_to_js(array('status' => TRUE, 'content' => book_tree($nid, 5, array($nid))));

   
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = 'node/%d' AND module = 'book' ORD\
ER BY mlid ASC"
, $nid, 0, 1));

    if (
$mlid) {
     
$item = menu_link_load($mlid);
     
$subtree = book_menu_subtree_data($item);
      print
drupal_to_js(array('status' => TRUE, 'content' => menu_tree_output($subtree) ));
    }

  }
  print
drupal_to_js(array('status' => TRUE, 'content' => '' )); // return something so the spinner doesn't go on forever
}
?>

If someone really wants I can make a proper patch, but I don't have the Drupal CVS set up on the machine where I made this change. And it's a change to a very small file.

#4

nedjo - June 18, 2008 - 17:19

Thanks for submitting the fix!

Anyone available to test and mark RTBC?

#5

geilhufe - June 19, 2008 - 22:20

Tested and did not work for me.
Menus did not expand and got this warning:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORD\ ER BY mlid ASC LIMIT 0, 1' at line 1 query: SELECT mlid FROM community_menu_links WHERE link_path = 'node/0' AND module = 'book' ORD\ ER BY mlid ASC LIMIT 0, 1 in /..../sites/all/modules/activemenu/modules/book.inc on line 46.

I have four books and a multilevel hierarchy.

#6

nedjo - June 21, 2008 - 02:03
Status:active» fixed

I committed a patch that seems to work. Pls reopen if not.

#7

Anonymous (not verified) - July 5, 2008 - 02:13
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.