Skip to content
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

Is there a way to manage the navigation bar? #180

Open
karimmtarek opened this issue Jul 17, 2015 · 1 comment
Open

Is there a way to manage the navigation bar? #180

karimmtarek opened this issue Jul 17, 2015 · 1 comment

Comments

@karimmtarek
Copy link

Currently the pages are added to the navigation based on when it was publish.

  • Is there a way to decide which pages can be displayed?
  • Is there a way to re-order the navigation links?
@mekhovov
Copy link

mekhovov commented Jul 5, 2017

there is a way :)

create navigation, give it some handle, add pages and reorder them:

screenshot 2017-07-05 14 03 55

inside app you can get that navigation by handle

main_navigation = Storytime::Navigation.find_by(handle: "main")

and then just render it:

render main_navigation

i have helper method that renders main navigation if it exists and all the pages in other case, also added admin page link if current user is admin

def render_main_menu
    main_navigation = Storytime::Navigation.find_by(handle: "main")
    menu_html = if main_navigation
      render main_navigation
    else
      Storytime::Page.published.collect do |page|
        content_tag :li do
          link_to page.title, storytime.page_path(page)
        end
      end
    end
    if current_user&.admin?
      menu_html << content_tag(:li) do
        link_to t('defaults.admin'), storytime_admin_path
      end
    end
    menu_html.html_safe
  end

feel free to use it :)

i think that would be nice to include helper method like this to the core @bcroesch ?

in User model i have:

  def roles
    storytime_roles
  end

  def admin?
    roles.pluck(:name).include? ('admin')
  end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants