Muhammad Ateq Ejaz
Muhammad Ateq Ejaz

Reputation: 1865

How to Display Refinery Admin Pages sitemap on front end Rails

I want to display Refinery Admin pages hierarchy on front end as a site map to my users, i'm new to RefineryCMS, can u please point to right direction? I have attached the image, that image comes under refinery/Admin section i want to add it on my site for visitors too, u can imagine i have a controller site_maps and action index and i want to display that site map under app/views/site_maps/index.html.erb page. Hope it make sense. Thanks.

enter image description here

Upvotes: 0

Views: 308

Answers (2)

Muhammad Ateq Ejaz
Muhammad Ateq Ejaz

Reputation: 1865

I implemented this by performing following steps.

1: In controller (mine is site_maps.rb)

class SiteMapsController < ApplicationController

def index
@pages = Refinery::Page.where(parent_id:nil)
end
end

2nd: in index.html.erb View

<div class = "row">
<%@pages.live.each do |page|%>
   <% if page.show_in_menu%>
   <ul>
   <li>
      <%= link_to (page_title_with_translations page),     refinery.url_for((page.url_marketable)) %>
      <%if page.children.any?%>
           <%= render :partial => 'shared/page', locals: {:page_children => page} %>
      <%-end %>
   </li>
  </ul>
  <%end%>
<%end%>

</div>

3rd: in _page.html.erb

<% page_children.children.live.each do |children_page|%>
  <ul>
  <li>
    <%= link_to (page_title_with_translations children_page), refinery.url_for((children_page.url_marketable)) %>
    <%if children_page.children.any?%>
        <%= render :partial => 'shared/page', locals: {:page_children => children_page} %>
    <%-end %>
  </li>
</ul>
<%end%>

NOTE: Without This refinery function refinery.url_for your links might be detected as spider's search and will get wrong!!

Upvotes: 2

ShivamD
ShivamD

Reputation: 971

Do you mean as the homepage? then:

mount Refinery::Core::Engine, :at => '/'

Upvotes: 0

Related Questions