Download & Extend

text "array" renders on node when menu trails is activiated

Project:Menu Trails
Version:6.x-1.0
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

First of all, thank you so much for this module! This was exactly what we needed to get our menu structure in order without going crazy. :)

I have applied a menu trail to my FAQ nodes, but when I do the word "array" is somehow output on my node. As far as I can tell it only does it for this content type. Any ideas? Perhaps it is something with the FAQ module?

Screeny: http://img503.imageshack.us/img503/8950/ss20081209105450nj8.png

Comments

#1

i should also note that this only renders for anonymous users... when i am logged in as admin the text does not show up. perhaps this is a permissions issue?

#2

Component:Miscellaneous» Code
Category:support request» bug report

Seems you never got an answer...
Found the same problem.
I think I found what goes wrong:

in menutrails.module the last function contains a variable $link which contains an array but is reused to produce output under certain conditions. If none of the conditions are met, the array value is still there when $link is passed to the $output variable.

I didn't do any deeper investigation, but it seems to work...

function phptemplate_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
        $class .= ' active';
      }
     
      if (isset($link['href'])) {
        // add active class for containing <li> and <a> if active-trail is set on the link itself
        if (strpos($link['attributes']['class'], 'active-trail') !== FALSE && strpos($class, 'active') === FALSE) {
           $class .= ' active';
           $link['attributes']['class'] .= ' active';
         }
        // Pass in $link as $options, they share the same keys.
        $linkit = l($link['title'], $link['href'], $link);//<----------------- I changed the $link variable to $linkit... see also further on
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $linkit = '<span'. $span_attributes .'>'. $link['title'] .'</span>';//<----------------- Also here I changed the $link variable to $linkit...
      }

      $i++;
      $output .= '<li '. drupal_attributes(array('class' => $class)) .'>';
      $output .= $linkit;//<----------------- ----------------------------------------------And here we send it to the $output variable in stead of the $link variable that stood here...
      $output .= "</li>\n";
    }

    $output .= '</ul><!--'.print_r($links,true).'-->'; //<------------------------------ to see the contents of the $links variable
  }
  return $output;
}

#3

Status:active» fixed

Thanks for reporting! Committed a fix for this bug.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

#4

Status:fixed» closed (fixed)

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

nobody click here