Best Way To Do Front-end Public And Restricted Area With October CMS?
I have to create a website with limited public access pages.
All pages have a header section with a signin / signup link and when the user is already logged in, a logout link. To do this, I must place the rainlab user plugin session component in my layout with security=all (to prevent the ajax onLogout administrator error from being detected)
But by doing this, I can no longer use this layout for restricted access pages.
So, what is the right way to do it?
I thought of using 2 layout, one to public access with security = all and one to restricted access with security=user, but I'm not really satisfied to have to use 2 layout for a difference so minimal
any smarter solution ? thanks by advance
Answer
You can use the same layout for both restricted and public pages. Add the [session] component reference to the layout but don't set properties on it in the layout itself. Set the 'security' property on a per page (and not on the layout itself) basis.
So the top of your layout would look something like:
name="Master Layout"
description = "Master layout for almost all frontend pages."
[session]
==
<!DOCTYPE html>
<html lang="en">
<head>
.....
And the top of your pages would look like:
title = "Restricted Page"
url = "/classified"
layout = "master"
[session]
security = "user"
redirect = "account"
==
<div class="container">
I use it all the time without a problem.
Related Questions
- → October CMS - cannot select themes
- → Page URLs not working
- → Best way to do front-end public and restricted area with October CMS?
- → Laravel 5 Deleting a one-to-many relationship
- → How to develop Shopify themes locally?
- → Remove h1 class="page-title" from ENFOLD theme
- → How can I render a theme partial from within a component
- → show product vendor on collection page
- → Custom made sections not appearing with Shopify's new theme editor
- → How to edit content on pages for Collection Tags in Shopify
- → How to test shopify themes locally?
- → Shopify - Increment or Counter
- → October CMS: share partial between themes