Context Module allows for setting a primary or secondary link active when certain conditions are met (i.e certain node types are being viewed). The Context Module adds an "active" class to the selected menu <li> that is not showing up in Fusion based themes due the Fusion Core preprocess page function and how Superfish is implemented. By checking <?php print theme('links', $primary_links); ?>, the proper Context functionality is observed, while with <?php print theme('grid_block', $primary_links_tree, 'primary-menu'); ?>, it is not. However, without the latter, Superfish doesn't work. To observe the difference, take a look at both print statements side by side in firebug and note the classes. I think it is important to get Fusion Core compatible with the Context Module due to it's huge potential and growing adaptation. I'll continue to post any progress.
Comments
Comment #1
brentratliff commentedUPDATED
Works for case when Primary Menu dropdown is disabled according to
function fusion_core_preprocess_page(&$vars)It has different class assignments but easily selectable with css. The problem with Superfish is the replacement of classes in
$vars['primary_links_tree'] = preg_replace('/<ul class="menu/i', '<ul class="menu sf-menu', $vars['primary_links_tree'], 1);Somehow the active class needs to be left in when the string is replaced if dropdown menus are selected in theme settings.
Comment #2
brentratliff commentedPossibly some logic in:
, to check for the 'active' string in $element and leave it alone?
Comment #3
brentratliff commentedThis can be done in a module using
function hook_menu_link_alter(&$item, $menu)but I'm still hoping to handle it in the theme layer so all Fusion themes can use it. Thoughts?Comment #4
brentratliff commentedCurrently using jQuery for this functionality by selecting a class added with the Menu Attributes module. I may visit this later to get the functionality in Fusion Core without Javascript.
Comment #5
martysteer commentedThe fusion template preprocess logic which builds the $primary_links_tree var for the superfish scripts also strips out any CSS menu id's. I think the Menu API in Drupal is doing this.
Comment #6
sociotech commentedbrentratliff,
This appears to be a functionality gap. In order to create a Superfish dropdown menu, we have to use a a menu tree structure, but (according to #586396: Context Active menu problem) Context module only adds its active class to standard primary and secondary menus, not menu tree structures.
So this is probably a problem for any combination of Context and a theme or module that creates dropdown menus. Though if you know of a generic dropdown menu solution that works with Context I'd be eager to hear about it.
The issue above includes several possible fixes, but I'd really like to avoid adding module-specific code to Fusion. From experience, it usually ends up creating more issues for users than it fixes.
Ideally, the solution would be for Context module to add its classes to menu tree structures as well, but that's an issue for its developers to consider.
In the meantime, perhaps you could post your JQuery solution here for others who are having this problem.
In conclusion, I'm open to suggestions for solutions to this issue that don't involve adding module-specific code to Fusion, but I don't otherwise see that there's much we can do to fix the problem at our end.
Comment #7
brentratliff commentedSociotech,
Thanks for looking into this issue. I agree that you don't want to go down the road of adding unique fixes based on contrib modules. There seems to be a code snippet in http://drupal.org/node/586396 that is working for some. This is the jQuery solution I used:
I added a class to each primary link menu item with http://drupal.org/project/menu_attributes.
For each logical section in which I wanted the active class, I added the following snippet to the appropriate template file: (views, node, etc)
#eventmenu is the id added with the menu attributes module. It will need to be changed for each logical section (primary link item in my case). It's not ideal but works great. Google Analytics shows almost all my visitors have javascript enabled. Hopefully it will help someone.
Comment #8
sociotech commentedbrentratliff,
Thanks very much for posting your JQuery-based solution.
I'd also be interested to hear if anyone has tried to fix the issue by adding this snippet from the Context issue you referenced to a template.php file in their Fusion subtheme: http://drupal.org/node/586396#comment-2608608
The only thing I can see that should be modified in that snippet is to change the function name from phptemplate_menu_item() to SUBTHEMENAME_menu_item(), where SUBTHEMENAME is the name of your subtheme (e.g., acquia_prosper).
While I don't think it would be a good idea to add something this module-specific to Fusion Core, it would be helpful to know if it's a reliable fix that could be dropped in on an as-needed basis.
Thanks.
Comment #9
wigglykoala commentedI'm having this issue with 6.x-1.0 I tried http://drupal.org/node/586396#comment-2608608 but no luck. I'm not using spaces which seems to be causing the problem as I am getting a fatal error
Fatal error: Call to undefined function spaces_get_space()
Think I will have to try the jQuery way next as my PHP isn't good at all!!
Comment #10
wigglykoala commentedremoved
and now I get "warning: Invalid argument supplied for foreach() in.... /sites/all/themes/fusion/fusion_core/template.php on line 541."
I am pasting this is into fusion core which I know isnt best practise, but I just want to get it to work before doing anything else!
Comment #11
hedac commentedhas anyone fixed this context compatibility with Fusion superfish menus?
subscribing
Comment #12
BlueBlossom commentedsubscribing
Comment #13
malapeiro commentedhi, dont know how to code, but i solve this issue with menu position module (https://drupal.org/project/menu_position) instead of context module. it works for me!
Comment #14
Poieo commentedClosed as won't fix since the D6 version is no longer supported.