Search code examples
ruby-on-railsruby-on-rails-3refinerycms

RefineryCMS trying to tweak layout per page


I'm new to RefineryCMS and still pretty new to rails as well. What i'm trying to do, is use the same header and footer in my layout file and then in the dynamic section that gets pulled from the CMS database, use different markup per page.

Example template:

<header>
...
</header>

# want to insert "home" page or "about" page here depending on url.

<footer>
...
</footer>

Example of what i want home page to have inserted into template:

<div>
  <%= raw @page.content_for(:body) %>
</div>

Example of what i want about page to have inserted into template:

<div>
  <div>
    <div>
      <%= raw @page.content_for(:body) %>
    </div>
  </div>
</div>

How can i change the markup per page without having to add the markup in the wysiwyg editor in the CMS?


Solution

  • Which version are you using?

    If you're using 2.0.x, then there are two options inside config/initializers/refinery/pages.rb — the first one should be config.view_template_whitelist, and the second one should be config.use_view_templates.

    For config.view_template_whitelist, you can specify an array of symbols that match to views inside your app/views/refinery/pages/ folder (i.e. if you have about_us.html.erb, you would whitelist [:about_us], just as you might if you were going to say render :about_us inside your controller.

    config.use_view_templates simply needs to be set to true to enable the dropdown in the backend that will let you choose a template from your whitelist.

    If you're curious, there also exists config.layout_template_whitelist and config.use_layout_template options too that do the same, but with layouts.