alchemy-cms

How to set page layout using page_layouts.yml?


I need to set the page layout, currently, I can see that the used page layout file is application.html.haml

how would I let the page use another file as the layout? I thought it would be possible by using page_layouts.yml by setting the name but it seems I still missing how to do it. What does that name relates to? for now, its value is index but where is that index file?

Any idea?

EDIT

I could handle this but only worked at show page as:

class ApplicationController < ActionController::Base
  layout :determine_layout

 def determine_layout
    module_name = self.class.to_s.split("::").first
    return (module_name.eql?("Alchemy") ? "pages" : "application")
  end

However, I still need to apply this while editing the page at admin page.


Solution

  • The application.html.erb file is the template for the whole Rails application. Alchemy pages have their own templates per page_layout stored in the app/views/alchemy/page_layouts folder.

    Please read the guideline on how to create a page layouts and templates

    https://guides.alchemy-cms.com/pages.html#page-templates

    EDIT:

    You are able to set the layout used in the admin page edit preview with the admin_page_preview_layout setting in the config/alchemy/config.yml.

    https://github.com/AlchemyCMS/alchemy_cms/blob/main/config/alchemy/config.yml#L205