What options allow setting the PARENT MENU field dynamically?

Use Case example

Defined Drupal menu tree:

MAIN
-A
--a.1
--a.2
-B
--b.1
--b.2
-C
--c.1
--c.2
---c.2.1
---c.2.2

Superfish block installed and enabled for all pages.

Would like the menu block to start at various points in menu tree depending on context or rule. For example, user presses some top menu item, the pass c.2 as parent menu item shows just that portion of tree. Node taxonomy is yyy, then pass C and that portion of tree is shown. Even, showing different parts of menu tree structure based on url link structure same as how blocks are shown or hidden.

Certainly, digging and modding module can accomplish but was hoping maybe there is some way to set the parent menu variable more easily in time for the superfish block to use it.

Comments

windtrader’s picture

Issue summary: View changes

format

mehrpadin’s picture

Hey Don, or should I say Ohayo Don :)

It's not possible, however I think I add such a thing in v2.

mehrpadin’s picture

Issue summary: View changes

format

jessehs’s picture

Issue summary: View changes

You can accomplish this by copying the "theme_superfish" function out of the superfish.module file, and putting it in the theme's template.php file, renamed as "mythemename_superfish($variables)".

Then add some custom code at the top of the function to dynamically set the $mlid variable:

// Set the menu parent mlid based on current active trail.
  $active_trail = menu_get_active_trail();
  switch ($active_trail[1]['href']) {
    case 'foo':
      $mlid = 1234;
      break;
    case 'bar':
      $mlid = 2345;
      break;
    case 'baz':
      $mlid = 4567;
      break;
  }

It would be best if you could not hard-code mlid's into the function, but in my case the active trail was not being set correctly.

LOBsTerr’s picture

Status: Active » Closed (outdated)