Search code examples
layoutrefinerycms

Getting a collection of pages with refinerycms


I've been customising refinerycms with my limited knowledge of ruby/rails, and I've come across a problem:

After changing the application.html.erb to my preferred look, I have removed

<%= yield %>

And replaced it with

<%= @page.content_for(:body).html_safe %>

Now in my application.html.erb, I have a navigation menu. I'd like to get a list of contructed pages and parse them into the menu, ie Home, About Us, Contact Us etc...


Solution

  • Ok, found the answer, I put the <% yield %> back in the application.html.erb file.

    Then I accessed the list of pages by using

    <% @Pages = Page.in_menu %>
    <% @Pages.in_menu.each do |p| %>
      <li><a>p.title</a></li>
    <%end%>
    

    Still not sure how to generate a link href though, it works if you do /p.title, but if you have a space in the title it breaks, I'll update the answer when I find it.

    @parndt: Thanks for pointing me in the right direction on IRC