I am currently trying to update an existing RefineryCMS app from gem version so I can be up to date add bootstrap 3 at the same time.
gem "refinerycms", "~> 2.0.10"
to
gem "refinerycms", "~> 2.1.0"
After removing outdated blocks and deleting a couple overridden views from the site's past I have got the site successfully functioning again with its current database's content.
Now that Refinery has switched over to the Menu Presenter in exchange of the old partials. How can I add, remove and edit the classes of all elements within the new Menu Presenter system?
I would like to have control of the surrounding div's to the most inner <"li"> an <"a"> children elements.
I have been looking at the http://refinerycms.com/guides/menu-presenter guide. I think I understand this guide as a way of adding a secondary menu to the footer of your footer declared pages. So only specific pages that are not in the existing menu at the top will populate the menu explained in the example.
I apologize for my lack of understanding, but I am having a hard time using this example to answer my question above about Refinery's initial main menu's classes.
Not entirely sure what you're trying to achieve, but I think the answers are all in the source of Menu_Presenter: https://github.com/refinery/refinerycms/blob/master/pages/app/presenters/refinery/pages/menu_presenter.rb
You should be able to set the attributes on a presenter then render the menu thus:
presenter = Refinery::Pages::MenuPresenter.new(menu_items, self)
presenter.first_css = "my_first_item_class"
presenter.last_css = "my_last_item_class"
presenter
To style the links ( elements) just set "link_tag_css" on your MenuPresenter.
If you're trying to do something with nested dropdowns for Bootstrap, that could get a little more complicated. The trouble, as you probably know; with Bootstrap if you want dropdowns you need to insert data attributes to various link elements.
This post: Rails Bootstrap Navbar and refineryCMS gives a method to override MenuPresenter, but I haven't read and understood the code fully and it needs a couple of tweaks. Worked OK for me, though I am sure there are more elegant ways to achieve nice nested menus.
来源:https://stackoverflow.com/questions/18294061/editing-refinerycms-2-1-menu-presenter-to-manipulate-dom-id-css-and-other-attrib