Because the current version does not play well with the Menu Block module in that only a menu can be chosen, not a menu block, i request the feature to add at least the starting level as Superfish menu setting. Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mehrpadin’s picture

Hoi Yuri,

I guess you're using v1.8-beta2 .

Yuri’s picture

No, I'm using the most recent version 1.8
If you refer to the "menu parent" selection box available in Superfish, that is something different than what I mean.
Menu Block uses "starting level" which works dynamically, it shows menu items if they are on the selected level or lower and the menu will show the items if they have the active_trail class.
This is different from the menu parent selection box which can only select one parent in one branch.

mehrpadin’s picture

Oh! I got it, sure, added to my to-do list, thank you! really!

flatcircle’s picture

I this already a feature in the latest version? (7.x-1.8)
Is it possible to not only set the menu depth but also the starting level?

Regards.

mehrpadin’s picture

Hey,

Not yet, with 1.9-beta5 hopefully.

:)

sigurdur’s picture

Hi, I'm facing the same problem.

I'm using taxonomy, with Taxonomy Menu to split my site into sections, i.e. with the top level terms in a section menu at the top and then a split menu, using the same vocabulary, but level 2 and below for navigation in each section. This is possible with Menu Block, but I would prefer using Superfish. Any news on this?

Best regards,
Sigurdur

softone’s picture

Hi.

It seems it's not yet included in 1.9-beta5.

This would be a very good and valuable addition to the Superfish features :-)

Regards.

shortspoken’s picture

Subscribing +
Would be an awesome feature!
Cheers, Moritz

McGrathOS’s picture

Subscribing

rudetrue’s picture

Subscribing

BartNijs’s picture

Subscribing. Need this feature as well.
Any alternatives for now?

sherpadawan’s picture

I'm very sorry for this quick and dirty work, but hopefully it'll kickass somebody to do it. The thing is that menu block is great, is there any integration between both superfish and menu block ? Maybe the reflexion is higher level anyway ...

start level is : the level from the selected menu root level (pretty bad usecase coverage)
follow start level is : do you want to see the same thing in the block after clicking on a sublink (very bad usecase coverage as well since it does not show children in case)

that's why i'm wondering about a fusion with menu blocks code ...

here is my patch

diff --git b/src/sites/all/modules/contrib/superfish/superfish.module a/src/sites/all/modules/contrib/superfish/superfish.module
old mode 100644
new mode 100755
index 850964f..d0b9b12
--- b/src/sites/all/modules/contrib/superfish/superfish.module
+++ a/src/sites/all/modules/contrib/superfish/superfish.module
@@ -86,6 +86,19 @@ function superfish_block_configure($delta = 0) {
     '#default_value' => variable_get('superfish_menu_' . $delta, 'main-menu:0'),
     '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)),
   );
+  $form['sf-menu']['superfish_menu_start_level_' . $delta] = array(
+    '#type' => 'select',
+    '#title' => t('Menu starting level'),
+    '#description' => t('The menu starting level you want to be displayed using Superfish.') . ' (' . t('Default') . ': <0>)',
+    '#default_value' => variable_get('superfish_menu_start_level_' . $delta, '0'),
+    '#options' => drupal_map_assoc(range(-1,10)),
+  );
+  $form['sf-menu']['superfish_menu_start_level_follow_' . $delta] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Make the starting level follow the active menu item'),
+    '#description' => t('Make the starting level follow the active menu item') . ' (' . t('Default') . ': <no>)',
+    '#default_value' => variable_get('superfish_menu_start_level_follow_' . $delta, '0'),
+  );
   $form['sf-menu']['superfish_depth_' . $delta] = array(
     '#type' => 'select',
     '#title' => t('Menu depth'),
@@ -656,6 +669,8 @@ function superfish_block_configure($delta = 0) {
 function superfish_block_save($delta = 0, $edit = array()) {
   variable_set('superfish_name_' . $delta, $edit['superfish_name_' . $delta]);
   variable_set('superfish_menu_' . $delta, $edit['superfish_menu_' . $delta]);
+  variable_set('superfish_menu_start_level_' . $delta, $edit['superfish_menu_start_level_' . $delta]);
+  variable_set('superfish_menu_start_level_follow_' . $delta, $edit['superfish_menu_start_level_follow_' . $delta]);
   variable_set('superfish_depth_' . $delta, $edit['superfish_depth_' . $delta]);
   variable_set('superfish_type_' . $delta, $edit['superfish_type_' . $delta]);
   variable_set('superfish_style_' . $delta, $edit['superfish_style_' . $delta]);
@@ -728,6 +743,9 @@ function superfish_contents($delta = 0) {
 
   list($menu_name, $mlid) = explode(':', variable_get('superfish_menu_' . $delta, 'main-menu:0'));
 
+  $menu_start_level = variable_get('superfish_menu_start_level_' . $delta, 0);
+  $menu_start_level_follow = variable_get('superfish_menu_start_level_follow_' . $delta, 0);
+
   $sfsettings = $sfoptions = $sfplugins = array();
   $sfsettings['depth'] = variable_get('superfish_depth_' . $delta, '-1');
   $sfsettings['type'] = variable_get('superfish_type_' . $delta, 'horizontal');
@@ -998,6 +1016,8 @@ function superfish_contents($delta = 0) {
     'id' => $delta,
     'menu_name' => $menu_name,
     'mlid' => $mlid,
+    'menu_start_level' => $menu_start_level,
+    'menu_start_level_follow' => $menu_start_level_follow,
     'sfsettings' => $sfsettings
   );
   if ($output = theme('superfish', $vars)) {
@@ -1539,18 +1559,34 @@ function superfish_build_page_trail($page_menu) {
  */
 function theme_superfish($variables) {
   global $user, $language;
-
   $id = $variables['id'];
   $menu_name = $variables['menu_name'];
   $mlid = $variables['mlid'];
+  $menu_start_level = $variables['menu_start_level'];
+  $menu_start_level_follow = $variables['menu_start_level_follow'];
   $sfsettings = $variables['sfsettings'];
 
-  $menu = menu_tree_all_data($menu_name);
-
+  if ($menu_start_level == 'none') {
+      $menu = menu_tree_all_data($menu_name);
+  } else {
+      #ugly quick dev! not tested against module regular bahaviour
+      #get the root element according to the menu_start_level
+      if ($menu_start_level_follow == '0') {
+        $at =  menu_get_active_trail();
+        $active_trail = $at[$menu_start_level];
+      } else {
+        $active_trail    = array_pop(menu_get_active_trail());
+      }
+      $children_depth  = $active_trail['depth'] + $menu_start_level;
+      $menu_properties = array(
+                               'min_depth' => $children_depth,
+                               'conditions' => array('plid'=>$active_trail['mlid']),
+                              );
+      $menu = menu_build_tree($menu_name, $menu_properties);
+  }
   if (function_exists('i18n_menu_localize_tree')) {
     $menu = i18n_menu_localize_tree($menu);
   }
-
   // For custom $menus and menus built all the way from the top-level we
   // don't need to "create" the specific sub-menu and we need to get the title
   // from the $menu_name since there is no "parent item" array.
@@ -1914,4 +1950,4 @@ function theme_superfish_menu_item_link($variables) {
   $menu_item = $variables['menu_item'];
   $link_options = $variables['link_options'];
   return l($menu_item['link']['title'], $menu_item['link']['href'], $link_options);
-}
\ No newline at end of file
+}
BartNijs’s picture

Issue summary: View changes

sherpadawan,
I added your patch to superfish.module and now it does take the start level into account and only appears if the parent menu item is selected. But I get no depth. The menu only shows items on the same level.

Example to illustrate:

<ul>
  <li>foo (level0)
    <ul>
      <li>A (level1)
        <ul>
          <li>K (level2)</li>
          <li>L (level2)</li>
          <li>M (level2)</li>
          <li>N (level2)</li>
        </ul>
      </li>
      <li>B (level1)
        <ul>
          <li>O (level2)</li>
          <li>P (level2)</li>
          <li>Q (level2)</li>
          <li>R (level2)</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>bar (level0)
    <ul>
      <li>C (level1)
        <ul>
          <li>S (level2)</li>
          <li>T (level2)</li>
          <li>U (level2)</li>
          <li>V (level2)</li>
        </ul>
      </li>
      <li>D (level1)
        <ul>
          <li>W (level2)</li>
          <li>X (level2)</li>
          <li>Y (level2)</li>
          <li>Z (level2)</li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

When in a menu block the foo menu item is selected, the superfish block shows menu items A and B. But there's no submenus. The ul's below A and B are missing. When I click on A, the level 1 menu items disappear and make place for the level2 items. Thus showing K, L M and N.

I'm not a coder so I don't know where to start to resolve this issue. But for a first step your solution seems to be on the right path.

BlacKICEUA’s picture

Any solution for this problem? I found work patch on other site, but not remember the website address.

BlacKICEUA’s picture

I think, I found solution.

Thanks for sherpadawan!!!

This is my variant of patch:

diff --git b/src/sites/all/modules/contrib/superfish/superfish.module a/src/sites/all/modules/contrib/superfish/superfish.module
old mode 100644
new mode 100755
index 850964f..d0b9b12
--- b/src/sites/all/modules/contrib/superfish/superfish.module
+++ a/src/sites/all/modules/contrib/superfish/superfish.module
@@ -84,10 +84,23 @@ function superfish_block_configure($delta = 0) {
     '#title' => t('Menu parent'),
     '#description' => t('The menu you want to be displayed using Superfish.') . ' <em>(' . t('Default') . ': &lt;Main menu&gt;)</em>',
     '#default_value' => variable_get('superfish_menu_' . $delta, 'main-menu:0'),
     '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)),
   );
+  $form['sf-menu']['superfish_menu_start_level_' . $delta] = array(
+    '#type' => 'select',
+    '#title' => t('Menu starting level'),
+    '#description' => t('The menu starting level you want to be displayed using Superfish.') . ' (' . t('Default') . ': <0>)',
+    '#default_value' => variable_get('superfish_menu_start_level_' . $delta, '0'),
+    '#options' => drupal_map_assoc(range(-1,10)),
+  );
+  $form['sf-menu']['superfish_menu_start_level_follow_' . $delta] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Make the starting level follow the active menu item'),
+    '#description' => t('Make the starting level follow the active menu item') . ' (' . t('Default') . ': <no>)',
+    '#default_value' => variable_get('superfish_menu_start_level_follow_' . $delta, '0'),
+  );
   $form['sf-menu']['superfish_depth_' . $delta] = array(
     '#type' => 'select',
     '#title' => t('Menu depth'),
     '#description' => t('The number of child levels starting with the parent selected above. <strong>-1</strong> means all of them, <strong>0</strong> means none of them.') . ' <em>(' . t('Default') . ': -1)</em>',
     '#default_value' => variable_get('superfish_depth_' . $delta, -1),
@@ -654,10 +667,12 @@ function superfish_block_configure($delta = 0) {
  * Implements hook_block_save().
  */
 function superfish_block_save($delta = 0, $edit = array()) {
   variable_set('superfish_name_' . $delta, $edit['superfish_name_' . $delta]);
   variable_set('superfish_menu_' . $delta, $edit['superfish_menu_' . $delta]);
+  variable_set('superfish_menu_start_level_' . $delta, $edit['superfish_menu_start_level_' . $delta]);
+  variable_set('superfish_menu_start_level_follow_' . $delta, $edit['superfish_menu_start_level_follow_' . $delta]);
   variable_set('superfish_depth_' . $delta, $edit['superfish_depth_' . $delta]);
   variable_set('superfish_type_' . $delta, $edit['superfish_type_' . $delta]);
   variable_set('superfish_style_' . $delta, $edit['superfish_style_' . $delta]);
   variable_set('superfish_speed_' . $delta, $edit['superfish_speed_' . $delta]);
   variable_set('superfish_delay_' . $delta, $edit['superfish_delay_' . $delta]);
@@ -726,10 +741,13 @@ function superfish_contents($delta = 0) {
   global $language;
   $block_css = $block_js = array();
 
   list($menu_name, $mlid) = explode(':', variable_get('superfish_menu_' . $delta, 'main-menu:0'));
 
+  $menu_start_level = variable_get('superfish_menu_start_level_' . $delta, 0);
+  $menu_start_level_follow = variable_get('superfish_menu_start_level_follow_' . $delta, 0);
+
   $sfsettings = $sfoptions = $sfplugins = array();
   $sfsettings['depth'] = variable_get('superfish_depth_' . $delta, '-1');
   $sfsettings['type'] = variable_get('superfish_type_' . $delta, 'horizontal');
   $sfsettings['style'] = variable_get('superfish_style_' . $delta, 'default');
   $sfsettings['expanded'] = variable_get('superfish_expanded_' . $delta, 0);
@@ -996,10 +1014,12 @@ function superfish_contents($delta = 0) {
 
   $vars = array(
     'id' => $delta,
     'menu_name' => $menu_name,
     'mlid' => $mlid,
+    'menu_start_level' => $menu_start_level,
+    'menu_start_level_follow' => $menu_start_level_follow,
     'sfsettings' => $sfsettings
   );
   if ($output = theme('superfish', $vars)) {
     if (!empty($output['content'])) {
       $output['content'] = array(
@@ -1537,22 +1557,48 @@ function superfish_build_page_trail($page_menu) {
 /**
  * Theme function to allow any menu tree to be themed as a Superfish menu.
  */
 function theme_superfish($variables) {
   global $user, $language;
-
   $id = $variables['id'];
   $menu_name = $variables['menu_name'];
   $mlid = $variables['mlid'];
+  $menu_start_level = $variables['menu_start_level'];
+  $menu_start_level_follow = $variables['menu_start_level_follow'];
   $sfsettings = $variables['sfsettings'];
 
-  $menu = menu_tree_all_data($menu_name);
+  if ($menu_start_level == 0) {
+      $menu = menu_tree_all_data($menu_name);
+  } else {
+      #ugly quick dev! not tested against module regular bahaviour
+      #get the root element according to the menu_start_level
+      if ($menu_start_level_follow == '0') {
+        $at =  menu_get_active_trail();
+          if (array_key_exists($menu_start_level, $at)){
+              $active_trail = $at[$menu_start_level];
+          } else {
+              return;
+          }
+          $menu_properties = array(
+              'min_depth' => $active_trail['depth']+1,
+              'conditions' => array('p'.$menu_start_level=>$active_trail['mlid']),
+          );
+          $menu = menu_build_tree($menu_name, $menu_properties);
+      } else {
+          $active_trail    = array_pop(menu_get_active_trail());
+          $menu_properties = array(
+              'min_depth' => $active_trail['depth']+1,
+              'conditions' => array('plid'=>$active_trail['mlid']),
+          );
+          $menu = menu_build_tree($menu_name, $menu_properties);
+      }
+
 
+  }
   if (function_exists('i18n_menu_localize_tree')) {
     $menu = i18n_menu_localize_tree($menu);
   }
-
   // For custom $menus and menus built all the way from the top-level we
   // don't need to "create" the specific sub-menu and we need to get the title
   // from the $menu_name since there is no "parent item" array.
   // Create the specific menu if we have a mlid.
   if (!empty($mlid)) {
@@ -1912,6 +1958,6 @@ function theme_superfish_menu_item($variables) {
  */
 function theme_superfish_menu_item_link($variables) {
   $menu_item = $variables['menu_item'];
   $link_options = $variables['link_options'];
   return l($menu_item['link']['title'], $menu_item['link']['href'], $link_options);
-}
\ No newline at end of file
+}

sreher’s picture

Thanks BlacKICEUA.
I made a patch from this.
I try it and it works. :)

sreher’s picture

Status: Active » Needs review
TipiT’s picture

Patch #16 works most of the cases but if I set:
1.) Menu starting level to 1 and
2.) Make the starting level follow the active menu item" setting is on

I get an error:

Strict warning: Only variables should be passed by reference in theme_superfish() (line 1810 of .../sites/all/modules/superfish/superfish.module).

TipiT’s picture

Status: Needs review » Needs work
quixxel’s picture

The patch isn't working for me.
I'm getting the same error reported in #18 and the menu isn't starting on a defined level 1 or 2 or 3 ....
It would be very important for me to get the starting-level-feature.

BlacKICEUA’s picture

I think that these lines are wrong:

+} else {
+          $active_trail    = array_pop(menu_get_active_trail());
+          $menu_properties = array(

// Must be something like this:
$menu_active_trail = menu_get_active_trail();
$active_trail    = array_pop($menu_active_trail);
$menu_properties = array(
    'min_depth' => $active_trail['depth']+1,
    'conditions' => array('plid'=>$active_trail['mlid']),
);