SpinaCMS / Spina

Spina CMS
http://www.spinacms.com
Other
2.19k stars 405 forks source link

Feature Request: Ability to add resource pages to the navigation #1045

Closed wrystr closed 2 years ago

wrystr commented 2 years ago

First of all, I want to say thank you all for bringing this beautiful CMS.

I can't seem to add resource pages to a navigation, is this expected or are there settings somewhere I've missed?

I would be very grateful if this could happen. Sometimes I need to group pages into resources and display them but only what I want to display in the navigation.

For now I can work around this by using resources to create navigation and limiting it by utilizing the parent page and sub page level 1.

mweitzel commented 2 years ago

I've been recycling the MenuPresenter. Locally I have Spina::ResourceMenuPresenter with a the scoped_collection overriden:

module Spina
  class ResourceMenuPresenter < MenuPresenter
    def scoped_collection(collection)
      scoped = collection.active.in_menu.sorted
      include_drafts ? scoped : scoped.live
    end
  end
end

and then to use it I'll pass the collection I care about, e.g.

  <% presenter = Spina::ResourceMenuPresenter.new(current_page.resource.pages) %>
  <% presenter.config.list_css = "delightful-styles" %>
  <% presenter.config.current_list_item_css = "seriously-just-gorgeous" %>
  <% presenter.config.link_tag_css = "ok-maybe-i-have-bias" %>
  <%= presenter.to_html %>

So really just dropping the .regular_pages scope from the collection might give you what you want.

Bramjetten commented 2 years ago

While that's a good solution for creating a navigation menu in your frontend, I think @wrystr means he wants to add resource pages to the Spina::Navigation model from the UI in Spina. On a db-level, there's nothing that prevents us from doing that. The challenge is creating a nice UI for looking up pages and adding them. Resources can contain many (in our case 100s) of pages, making a simple select which we use now unusable. So: we need some sort of fancy PageSelectWithSearchComponent!

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.