codeplant/simple-navigation

Access Navigation Items in Code

silvermind opened this issue · 1 comments

It there a way to access the navigation items in model codes? The following does not work in non controller/View context:
items = SimpleNavigation::Helpers.render_navigation(renderer: :json, as_hash: true)

I'd like to render a sitemap having two locales with the already existing informations in navigation.rb using this gem: https://github.com/kjvarga/sitemap_generator#rails Is this possible? thanks

andi commented

No you do not have access to Navigation data in models since all navigation data is based on view-helpers. If you really need to use navigation data inside models (can't think of a use case though), you would have to pass the items in to a model method... Or you could access model data inside your navigation.rb file, if that helps...