How to add custom routes for my contents?

How to add custom routes for my contents? and how to show them with a custom layout + template?

  1. Add the hook "on_render_post" in your config/config.json
    ...
    "on_render_post": ["e_on_render_post"]
    ...
  2. Create the function listener for the hook in your main_helper.rb
    def e_on_render_post(args)
    if args[:post_type].slug == 'commerce' && params[:amp_page].present? # define what kind of contents and check the custom param added in route
    args[:layout] = 'blog' # put the name of your custom layout
    args[:render] = 'template_sample_page' # put the name of your custom template
    end
    end
  3. Add your custom routes on MYAPP/config/routes.rb
    Rails.application.routes.draw do
    scope 'amp', controller: "camaleon_cms/frontend" do
    get ":slug(.:format)" => :post, :as => :amp_page, defaults: {amp_page: true}
    end
    end
  4. Restart the server and enjoy

Now you can access to your content by two ways, like:

Created at: 10 Feb 16:57 | Updated at: 10 Feb 17:09