How to add custom routes for my contents? and how to show them with a custom layout + template?
- Add the hook "on_render_post" in your config/config.json
...
"on_render_post": ["e_on_render_post"]
... - 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 - 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 - 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