Blank browser screen when going to Menu Trails admin page

nessumsara - April 6, 2009 - 02:34
Project:Menu Trails
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:duplicate
Description

After installing and enabling Menu Trails on Drupal 6.10, I get a blank browser window when I try to go to
http://tap.resultsfordevelopment.org/drupal/admin/settings/menutrails

I'm assuming there is some kind of php error. Also when viewing pages on the site I get the following error.
"warning: Invalid argument supplied for foreach() in /home/www/tap.resultsfordevelopment.org/drupal/sites/all/modules/menutrails/menutrails.module on line 130."

I tried commenting out the following lines from menutrails.module. The warning I received on front end pages went away, but the blank screen for the admin page still occurs.

//    foreach ($node->taxonomy as $term) {
//     if ($term_trails[$term->tid]) {
//        $href = $term_trails[$term->tid];
//      }
//    }

Any assistance in pinpointing the cause of the problem would be greatly appreciated.

#1

Jim Kirkpatrick - April 8, 2009 - 18:23
Category:support request» bug report
Status:active» needs work

There are a couple of bugs caused by Menutrails unfortunately assuming the presence of the Taxonomy module, so when it's not things go bang. The admin screen blows up on 252 for a similar reason.

I've made a fix by:

  • Wrapping the foreach block at line 130 with an if statement:
    <?php
     
    if ($node->taxonomy) {
        foreach (
    $node->taxonomy as $term) {
          if (
    $term_trails[$term->tid]) {
           
    $href = $term_trails[$term->tid];
          }
        }
      }
    ?>
  • Wrapping the request to get taxonomy vocabularies on line 252 with a module_exists check:
    <?php
     
    if (module_exists("taxonomy")) {
       
    $vocabs = taxonomy_get_vocabularies();
      }
    ?>
  • Similar on line 270 now that $vocabs can be empty:
    <?php
     
    if ($vocabs) {
        foreach (
    $vocabs as $vocab) {
          if (
    $vocab->tags != 1) {
           
    // tagging gets out of hand too fast, so we disallow
           
    $form[$vocab->vid]['menutrails_terms'] = array(
             
    '#tree' => TRUE,
             
    '#type' => 'fieldset',
             
    '#collapsible' => TRUE,
             
    '#collapsed' => TRUE,
             
    '#title' => t('Categories:') ." $vocab->name",
            );
           
    $terms = taxonomy_get_tree($vocab->vid);
            foreach (
    $terms as $term) {
              
    $form[$vocab->vid]['menutrails_terms'][$term->tid] = array('#type' => 'select',
               
    '#title' => t('Parent item for') ." $term->name",
               
    '#default_value' => $term_trails[$term->tid],
               
    '#options' => $options,
              );
            }
          }
        }
      }
    ?>

After the above 3 checks are added, there are no more problems for me.

Jim

#2

Jim Kirkpatrick - April 8, 2009 - 18:38
Status:needs work» duplicate

Ahhh bugger. I spotted the above is already reported (and fixed in dev) in #313556: Missing dependency declaration for taxonomy module just after I posted the above.

#3

nessumsara - April 15, 2009 - 17:55

Sorry for the delayed response. I implemented the dev version and now it works fine. Thanks for saving my day and thanks to Josh K for fixing the problem!!

#4

axel-at-konzepto.net - September 26, 2009 - 18:51

subscribing

 
 

Drupal is a registered trademark of Dries Buytaert.