Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Is there any way to use the Foundation Navigation with the drupal core menu module?
Comment | File | Size | Author |
---|---|---|---|
#33 | Screen Shot 2013-04-11 at 4.52.17 PM.png | 71.44 KB | Anonymous (not verified) |
#28 | 1825876-1.patch | 3.92 KB | kevinquillen |
#26 | 1825876.patch | 3.07 KB | kevinquillen |
#24 | zurb-foundation-menuattributes-1825876-24.patch | 569 bytes | chrisjlee |
#24 | interdiff.txt | 569 bytes | chrisjlee |
Comments
Comment #1
micheas CreditAttribution: micheas commentedI use display suit http://drupal.org/project/ds to apply the classes.
Comment #2
lsolesen CreditAttribution: lsolesen commentedShouldn't this be handled by the theme? If you do not use display suite to anything else, it seems like overkill?
Could one use the same navigation for both mobile navigation and regular navigation?
Comment #3
ishmael-sanchez CreditAttribution: ishmael-sanchez commented@derMatze yes use the function below, I'm using it and it works just fine and I have committed it to the STARTER/template.php but left it commented out for themers to use it or not.
@micheas I agree with lsolesen DS for something like this is way overkill and it's nice to have a responsive dropdown menu out the box.
@lsolesen please use the function above or please provide suggestions to improve. Also in general there are different modules for handling menus: superfish, nice_menus, megamenu, so I still want the theme to be flexible to support those options along with core menu rendering.
Comment #4
derMatze CreditAttribution: derMatze commentedLooks very promising, but in my case the function MYTHEMENAME_links__system_main_menu gets never called.
Do you have any idea, why this happens?
I'm using this to call the menu within my page.tpl.php:
Comment #5
alexander.sibert CreditAttribution: alexander.sibert commentedI activated the code lines in the template.php in my template folder with following code but it works not.
Comment #6
alexander.sibert CreditAttribution: alexander.sibert commentedSorry, now it works. It was the cache :)
Comment #8
chrisjlee CreditAttribution: chrisjlee commentedShould this nav-bar be enabled by default?
Comment #9
ishmael-sanchez CreditAttribution: ishmael-sanchez commented@chrisjlee I have thought about this and gone back and forth. On one hand it's nice that it would work out of the box, on the flipside what if you wanted to use the Vertical Nav or the Top Bar then you have to suppress that Nav Bar functionality.
Also what if the themer wanted to use a module like megamenu, superfish, nice_menus or some other module that handles just the responsive part of the navigation. That's kinda why I have the logic in the page template to use the block navigation first and if that's not available output the main menu. Your thoughts?
Comment #10
chrisjlee CreditAttribution: chrisjlee commented@ishmael-sanchez I think we should leave it on.
Eventually, we could have a theme setting turn navbar on and off. I think we should please 80% of the users not the 100%. Especially if this theme has to compete with bootstrap.
IMHO, by default, zurb foundation should look slick out of the box. Someone shouldn't need to do too much work to have it look like the foundation theme found on the zurb foundation documentation site. Also, if we can help them avoid using another module for menus i think that's a win for the zurb foundation theme.
Would you agree?
Comment #11
ishmael-sanchez CreditAttribution: ishmael-sanchez commented@chrisjlee good point ok I will implement this.
Comment #12
chrisjlee CreditAttribution: chrisjlee commentedGreat. Be sure to pull before you start working. I did some major changes to the template file that would cause you a huge merge conflict.
Comment #13
ishmael-sanchez CreditAttribution: ishmael-sanchez commentedyeah I saw that, thanks for the heads up.
Comment #14
ishmael-sanchez CreditAttribution: ishmael-sanchez commentedOk the fix has been committed, now by default navbar styling is applied to the main menu.
Comment #15
billyroebuck CreditAttribution: billyroebuck commenteddumb question... but do you need to use a menu module in addition to the code above? I added the code to my template.php and it looks like Foundation, but I can't get the 2nd level flyouts to show...
Comment #16
ishmael-sanchez CreditAttribution: ishmael-sanchez commented@billyroebuck no you do not need another menu module did you flush cache after adding the code to your template.php? Also make sure in your main menu you have two levels of menus i.e.
-Fruits
--Apples
--Oranges
--Lemons
-Cars
--Big car
--Small car
-Whatever
Comment #17
derMatze CreditAttribution: derMatze commentedI think the class-names in Foundation have changed:
flyout -> dropdown
has-flyout -> has-dropdown
Comment #18
ishmael-sanchez CreditAttribution: ishmael-sanchez commented@derMatze actually the official documentation uses the flyout see http://foundation.zurb.com/docs/navigation.php are you sure you aren't thinking of buttons, http://foundation.zurb.com/docs/buttons.php. Using has-dropdown seems to omit the downward arrow and extra spacing next to the menu item and still works (at least in Chrome) but I don't know if that's legit.
Do you have a link or more documentation that supports the class name change you posted about?
Comment #19
derMatze CreditAttribution: derMatze commentedAaah, I'm sorry, the "Nav Bar" uses flyout-classes, but the "Top Bar" uses dropdown-classes... Eben if I have no clue what the difference between these two could be.
Comment #20
chrisjlee CreditAttribution: chrisjlee commented@derMatze Check out the implementations of each on the foundation page that ishmael listed above:
http://foundation.zurb.com/docs/navigation.php
Comment #21
erinclerico CreditAttribution: erinclerico commentedTHEMENAME_links__system_main_menu breaks the Menu Attributes module when trying to add classes to individual menus:
I believe the Drupal call menu_tree_output() (includes/menu.inc) incorrectly ignores class names injected by menu_attributes.module.
Here is how menu_attributes.module adds it's class:
Looks kosher to me.
The supplied call THEMENAME_links__system_main_menu function calls menu_tree_output(menu_tree_all_data('main-menu')) - that's where the trouble begins.
If you trace the actual class array that is created there, and subsequently returned, you will find it ignores any classes present in it's named param $tree.
When I cribbed and hacked this call - I check for classes present and include them when found - and I get success.
See the PDF walk-thru supplied.
Thank you.
Comment #22
ishmael-sanchez CreditAttribution: ishmael-sanchez commentedHi @erinclerico,
Thanks for the detailed bug report. I took a look, so I was clobbering those attributes in the function because I wasn't passing them to the l function when creating the links. Attached is patch that adds them back, I tested and it seems to work with the menu attributes module. If someone else could verify I will commit.
Comment #23
chrisjlee CreditAttribution: chrisjlee commentedi get warning with that patch.
Notice: Undefined variable: link_attr in zurb_foundation_links__system_main_menu() (line 159 of /home/parallels/workspace/zf/sites/all/themes/zurb-foundation/template.php).
cleared the cache twice too and installed menu_attributes beforehand.
Comment #24
chrisjlee CreditAttribution: chrisjlee commentedI fixed the warning by adding the variable $link_attr; but the flyout stops working after that.
Comment #25
kevinquillen CreditAttribution: kevinquillen commentedThe HTML markup is just wrong- I will post a patch that fixes the main menu in just a moment.
Comment #26
kevinquillen CreditAttribution: kevinquillen commentedOkay, to get this to work and be nearly 100% of the markup found on this doc page:
http://foundation.zurb.com/old-docs/f3/navigation.php#btopCode
The one catch I saw was that any link that had children has to have Expanded checked off, or Drupal will not pass them off to the theme functions.
With this change, I was able to:
With the markup output like this, the Foundation scripts 'just work' for me as far as navigation goes.
Of course, if you have more than one menu that needs this functionality (besides main menu) you'd have to follow suit in your subtheme and override as needed.
You'll see that I am also stripping the #theme_wrapper from links in this patch- that keeps the Drupal core classes (first, leaf, collapsed, expanded) from being applied, and interfering with CSS or other markup.
One thing that is not in this patch- page.tpl.php needs cleaning up after this, because we (or I, rather) am not using the provided variable from zurb_foundation_preprocess_page() for the menu. I couldn't figure out how to obtain the menu in that fashion and theme it with the same functions. Your mileage may vary with this- but this got me MUCH closer to what I expected from the documentation.
Screenshot (ignore the style - its not finished):
http://i.imgur.com/x0CouVy.jpg
Comment #27
kevinquillen CreditAttribution: kevinquillen commentedIt seems like if you'd want to have the vertical nav with flyouts, you would override this in your sub theme and change the classes appropriately. But the 'flyout-toggle' and 'has-flyout' does not seem to apply to Top Bar.
Comment #28
kevinquillen CreditAttribution: kevinquillen commentedHere is a better patch that puts the section tag in page.tpl.php instead of return it as a wrapper from the theme override.
Comment #29
Anonymous (not verified) CreditAttribution: Anonymous commentedCan anyone share their working version of their template.php with the fix for the Navigation? I've been trying to follow the patches files listed above but I cannot get it to work. I appreciate your help.
Comment #30
kevinquillen CreditAttribution: kevinquillen commented#29, here is a pastebin.
http://pastebin.com/KP8mZVyb
Beyond this, add the Main Menu block in the Block system to your Navigation area. Then, make sure any menu links with children (in the Menu system) are set to expanded. This will let you create a deep nested top-bar drop down.
Comment #31
Anonymous (not verified) CreditAttribution: Anonymous commentedkevinquillen, Thanks so much for sharing the file. I was able to use it and everything seems to be working fine except for Menu link that shows up at the right side of the nav bar when the window is resized (for small devices). If I inspect the page, I can see that the code is there but it is not displaying. Does anybody is experiencing the same problem? Thanks in advance.
Comment #32
chrisjlee CreditAttribution: chrisjlee commentedComment #33
Anonymous (not verified) CreditAttribution: Anonymous commentedOK. I got everything working (almost everything) the only problem I am having now is that when I resize the window, and click on the menu link, the navigation links won't show up. I am missing anything? how do I make my navigation to show up once I click on the menu icon?
Comment #34
kevinquillen CreditAttribution: kevinquillen commentedSounds like you're missing the flyout toggle?
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commentedYes, and I don't know how I make make it work. I want it to display when I resize the window and click on the menu link to display the nav links.
Comment #36
chrisjlee CreditAttribution: chrisjlee commented@Giraldo:
I made a small mistake in the code. If you perform a git pull you should be able to see the difference. I'm assuming you're using the 7.x-4.x branch.
Comment #37
Anonymous (not verified) CreditAttribution: Anonymous commented@chrisjlee:
It worked! Thank you so much for all the time and effort you guys put into this.
Comment #38
chrisjlee CreditAttribution: chrisjlee commented@giraldo: No problem thank you for reporting this.
P.s. if you're working on the 4.x dev branch there's an important update that should fix the theme menu. This was just completed over the weekend.
Comment #40
slamorte CreditAttribution: slamorte commentedKevin,
Your pastebin isn't working now. The patch is failing for me too, maybe because I'm using 7.x-1.0-alpha1 and not the dev version.
Apparently this change wasn't commit to 7.x-1.0-alpha1, because turning on the Main Menu block just gives me a standard Drupal Main Menu. Leaving the Main Menu bock off does give the Zurb Navigation bar with sub menus, but does not give me sub-sub or lower menus, no matter what my expanded settings are.
If you could share a new pastebin with the changes or supply a patch for the 7.x-1.0-alpha1 that would be great. This has been a huge block for me.
I'm aso reactivating this bug because it does not appear to be fixed in 7.x-1.0-alpha1.
Comment #41
PeterEmil-1 CreditAttribution: PeterEmil-1 commentedHi all
Am I missing something? I can't get the Main Menu to appear as top-bar style. Nav-bar style works both with or without the Main Menu activated in the Navigation part of Blocks. (& that's very confusing for a person starting in Drupal...)
Is there un update or do I need to install Zurb Foundation 7.x-4.x to be able to switch from nav-bar to top-bar? The issue regarding this is closed but seems to me it's not "fixed" https://drupal.org/node/1934076
Help would be nice!
Comment #42
Kristina Katalinic CreditAttribution: Kristina Katalinic commentedMenu navigation is still not fixed because if you have more than 2 levels in the menu than it wont work
For example:
Parent
-- first child-- child of first child
Parent will get "expanded" and all classes required for drop down but first child will not and "expanded" class is stripped off
anyone has a working solution for this?
Comment #43
damiandab CreditAttribution: damiandab commentedFor me the mobile version of menu doesn't work at all :(
Comment #44
alexweber CreditAttribution: alexweber commentedThis has been fixed in the 7.x-4.x branch (which uses Foundation 4.x): #2020135: Basic theme settings for menu/mobile rendering
Not sure if it's an option to switch to it but that's where most of the work is going to be done for D7 going forwards...
Comment #45
ishmael-sanchez CreditAttribution: ishmael-sanchez commentedI agree with Alex, in the 1.x branch the theme uses Nav Bar via a custom function and the 4.x branch use Top bar and that's implemented and Alex has done a great job adding features to that functionality.
So if your are using 1.x branch look at the STARTER/template.php file there is a STARTER_links__system_main_menu($variables) which works and if you need to customize you can modify that function since it's in your STARTER theme.
If you are using the 4.x branch you you can reference zurb_foundation_links__topbar_main_menu and zurb_foundation_links__topbar_secondary_menu.