Editing RefineryCMS 2.1 Menu Presenter to manipulate dom_id css and other attributes

北慕城南 提交于 2019-12-06 00:24:45
CJBrew

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!