I was wondering if it was possible to do this: http://users.tpg.com.au/j_birch/plugins/superfish/#sample4 with pixture's superfish menu. If so, how would I go about doing that?

Any help with this would be appreciated.

Thanks,

Eric

Comments

ridolfidesigns’s picture

Anyone have an answer to this. I have been trying to figure it out with no luck.

bobgeier’s picture

Subscribing. Would love to figure this out as well for several themes.

ridolfidesigns’s picture

I did come up with something that works but it requires the use of nice menus as well. Here is what I did:

First, in pixture_reloaded's page.tpl.php there is code that looks like this:

  <?php if ((theme_get_setting('pixture_superfish')) && ($superfish)): ?>
    <script type="text/javascript">
      $(document).ready(function() {
        $('#superfish-inner ul').superfish();
      });
    </script>
  <?php endif; ?>

I then changed $('#superfish-inner ul') to $('ul.sf-menu')

After that, I needed to change drupal's .menu class to sf.menu sf-navbar because superfish's documentation states that the parent ul needs to have the class "sf.menu sf-navbar." So I first went into the template.php file to theme drupal's menu class but the problem was that when I changed the ul, it changed it for all of the ul's. That's where nice menus comes in.

Here is the code I added to my template.php file to make everything work the way I needed it to work:

function phptemplate_nice_menu($id, $menu_name, $mlid, $direction = 'right', $menu = NULL) {
  $output = array();

  if ($menu_tree = theme('nice_menu_tree', $menu_name, $mlid, $menu)) {
    if ($menu_tree['content']) {
      $output['content'] = '<ul class="sf-menu sf-navbar" id="sf-menu">'. $menu_tree['content'] .'</ul>'."\n";
      $output['subject'] = $menu_tree['subject'];
    }
  }
  return $output;
}

function phptemplate_nice_menu_build($menu) {
  $output = '';

  foreach ($menu as $menu_item) {
    $mlid = $menu_item['link']['mlid'];
    // Check to see if it is a visible menu item.
    if ($menu_item['link']['hidden'] == 0) {
      // Build class name based on menu path
      // e.g. to give each menu item individual style.
      // Strip funny symbols.
      $clean_path = str_replace(array('http://', '<', '>', '&', '=', '?', ':'), '', $menu_item['link']['href']);
      // Convert slashes to dashes.
      $clean_path = str_replace('/', '-', $clean_path);
      $path_class = 'menu-path-'. $clean_path;
      // If it has children build a nice little tree under it.
      if ((!empty($menu_item['link']['has_children'])) && (!empty($menu_item['below']))) {
        // Keep passing children into the function 'til we get them all.
        $children = theme('nice_menu_build', $menu_item['below']);
        // Set the class to parent only of children are displayed.
        $parent_class = $children ? 'menuparent ' : '';
        $output .= '<li id="menu-'. $mlid .'" class="'. $parent_class . $path_class .'">'. theme('menu_item_link', $menu_item['link']);
        // Build the child UL only if children are displayed for the user.
        if ($children) {
          $output .= '<ul class="submenu">';
          $output .= $children;
          $output .= "</ul>\n";
        }
        $output .= "</li>\n";
      }
      else {
        $output .= '<li id="menu-'. $mlid .'" class="'. $path_class .'">'. theme('menu_item_link', $menu_item['link']) .'</li>'."\n";
      }
    }
  }
  return $output;
}

Then I also added this line of code near the bottom where it looks to add additional stylesheets and javascript files:

drupal_add_css(drupal_get_path('theme', 'pixture_reloaded') .'/sf/css/superfish-navbar.css', 'theme');

Of course you have to have all of the necessary files in the theme folder. Because I was using pixture_reloaded, I just used the file structure that was already there. For example: there is a "SF" folder with a subfolder of "CSS", I simply added the superfish-navbar.css file.

That's about it. If anybody has any questions please let me know. Also, if you know how to create the code above that is related to nice menus without using the nice menus module, please let me know. I am not a programmer so I wasn't totally sure how to do it.

Thanks,

Eric

Jeff Burnz’s picture

Status: Active » Fixed

I think we can mark this one as fixed.

Status: Fixed » Closed (fixed)

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

robfrog’s picture

i just cant find this code in my page.tpl.php:

if ((theme_get_setting('pixture_superfish')) && ($superfish)):

$(document).ready(function() { $('#superfish-inner ul').superfish(); });

endif;
can you help me ridolfidesigns ?

cheers

rob

maen’s picture

Hello, I'm Marc from germany, I've been coming in touch with drupal for 2 weeks.

My Goal: Getting a horizontal menu in nav-bar style in pixture reloaded. Unfortunaletly, I got the same problem as robfrog...

The code

<?php
if ((theme_get_setting('pixture_superfish')) && ($superfish)):
?>

$(document).ready(function() {
$('#superfish-inner ul').superfish();
});

<?php
endif;
?> 

is not in page.

Also, I Don't understand this part of the explanation:

After that, I needed to change drupal's .menu class to sf.menu sf-navbar because superfish's documentation states that the parent ul needs to have the class "sf.menu sf-navbar." So I first went into the template.php file to theme drupal's menu class but the problem was that when I changed the ul, it changed it for all of the ul's. That's where nice menus comes in.

My question:
where is this .menu class and how to change it???

Has someone the pity to help a strict beginner please?????

Jeff Burnz’s picture

@mean - this thread is primarily about getting superfish working in OTHER themes, in Pixture Reloaded all you need to do is make a menu and place the block in the Superfish region (and disable primary links in your theme settings), thats all there is to it, its all automatic.