I'm trying to use Zurb foundation to style an app built with the latest version of refinery. I began by following this guide
http://blog.flatironschool.com/post/54511602806/build-a-blog-based-site-with-refinerycms
but the latest version of refinery uses "menu-presenter" to layout the menu.
I have got this far:
module ApplicationHelper
def zurb_menu
menu_items = Refinery::Menu.new(Refinery::Page.in_menu)
presenter = Refinery::Pages::MenuPresenter.new(menu_items, self)
presenter.css = "top-bar-section"
presenter.dom_id = nil
presenter.menu_tag = :section
presenter.list_tag = "ul class='left'"
presenter
end
end
This sort of works, However the elements aren't quite right and the main problem is that the I don't know how or where to add the dropdown class to make the child elements dropdown. With the code above the child elements are just expanded all the time.
Thanks for your help
You'll need to override the MenuPresenter. Specifically, you'll need to add the appropriate classes to the children of the top-level menu with the
render_menu_item
function. I'm not too familiar with Zerb Foundation, but this should get you started.Note: untested code, I just switched in some class names from my own Bootstrap menu solution to get you started, you might have to do a bit more work. I'm also adding your helper code to the overridden presenter, so you can just call it in a view like this:
<%= Refinery::ZerbMenuPresenter.new(refinery_menu_pages, self).to_html %>
app/presenters/refinery/zerb_menu_presenter.rb
This is my version... Tested; and it works for me at least.
I used the code for Bootstrap I found on another question (link in the comments above). But instead of replacing the entire menu presenter I override only the methods we need for this.
Create a Zurb menu presenter file:
app/presenters/refinery/pages/zurb_menu_presenter.rb
I have a helper in app/helpers/application_helpers.rb:
Then just call zurb_menu from the _header. I'm doing the Navbar stuff explicitly in my header function, which may or may not be right; you could roll that into the ZurbMenuPresenter class, and I may well do so:
app/views/refinery/_header.html.erb
instead of in_menu if you use fast_menu, then you will be able to reorder pages. menu_pages works, but you it will not render pages in the same order as they are in admin. hope this helps someone.
menu_items = Refinery::Menu.new(Refinery::Page.menu_pages)
menu_items = Refinery::Menu.new(Refinery::Page.fast_menu)