Render a section outside the Maglev layout
This guide mainly targets the users of the MIT version.
When developing your Maglev site, it might happen that you will need pages that won't necessarily be editable from the Maglev editor UI. For example, let's say you're deveveloping an e-commerce site and you are building the ERB template of the product detail page. Your product ERB template will certainly require 2 specific sections from your Maglev site: the navbar and the footer.
In order to fill that requirement, the Maglev engine comes with a Rails controller concern allowing the developer to render a specific section outside the Maglev ERB layout.
The content of those sections will only be editable from the Maglev pages only.
Inside your Rails controller
Your sections have to be site scoped to work outside the Maglev layout scope. See the documentation here and here for more explanation.
You first have to enhance your Rails controller by adding our custom controller concern.
The code below is based on the e-commerce site example we were talking about above.
Another solution to have access to the site scoped sections across all your controllers would be:
Inside your ERB template
If we have modified your application_controller
file instead, we would have put the code in charge of rendering the navbar and footer in the app/views/layouts/application.html.erb
.
Last updated