-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature suggestion: menu modification #138
Comments
I'm also following the Engines pattern and this little trick was awesome. Thanks! 👍 For a more "official" solution. |
I don't really know what to think about this. @andi do you have any thoughts on that subject? |
Wow, I wrote that gist an awful long time ago. 😀 I'm not sure how we can support this without cluttering the configuration code with Rails specifics. I think this is two things:
(Warning, thinking aloud follows!) Perhaps, for (1) we could introduce a For (2), we could add to the API to replace the invocation of: |
I think I would prefer 2)… But in general I’m not sure if this is an edge On Tue, Jul 29, 2014 at 3:04 PM, Mark J. Titorenko <notifications@github.com
|
I suppose a blog engine could want to add the "Blog" entry to the menu or something like that. If you adopt the completely decoupled approach to Rails with engines composition, it could probably make sense. |
Here is a use case from my application: I have a Rails app that is split up into many Rails engines. I have one Rails app that acts as the "top level" that includes all the other apps and sets up the layout. In that application I use Simple Navigation, and each engine needs to be able to plug into that interface to be able to display its navigation items. The way I "fixed" it was the following: In one of the engines (the SimpleNavigation::Configuration.run do |navigation|
engines = Rails::Engine.subclasses.map(&:instance).select do |e|
e.respond_to?(:navigation)
end
navigation.items do |primary|
engines.sort{|a,b| a.class.to_s <=> b.class.to_s }.each do |e|
e.navigation(primary, self)
end
end
end In each of the other included engines I have something like this (from the def navigation(primary, context)
primary.item :pages, {text: "Pages", icon: 'fa fa-cube'}, context.pages.root_path, if: proc{ context.can?(:read, Page) }, highlights_on: proc{ context.controller.class.name.split("::").first == "Pages" }
end This effectively lets each engine add its own navigation items to the menu. |
When putting some functionality of an app in engines, it can be useful to add something to the menu, or modify it. This is possible currently, but not documented and as such unclear if the method will keep working on updates.
Suggestion: add menu modification to the wishlist.
Perhaps it would be to (allow to) load menus from
<plugin>/config/navigation.rb
, but the order of loading would require some thought.I'm currently using this method based on this gist.
The text was updated successfully, but these errors were encountered: