使用 October CMS 执行 front-end public 和限制区域的最佳方法?

Best way to do front-end public and restricted area with October CMS?

我必须创建一个具有有限 public 访问页面的网站。

所有页面都有一个 header 部分,其中包含登录/注册 link 和当用户已经登录时,注销 link。为此,我必须将 rainlab 用户插件 session 组件放置在我的布局中,设置为 security=all(以防止检测到 ajax onLogout 管理员错误)

但是通过这样做,我不能再将此布局用于受限访问页面。

那么,正确的做法是什么?

我考虑过使用 2 种布局,一种用于 public 安全性 = all 访问,另一种用于 security=user 限制访问,但我不太满意必须使用 2 种布局来获得不同这么小

任何更聪明的解决方案?提前致谢

您可以对受限页面和 public 页面使用相同的布局。将 [session] 组件引用添加到布局,但不要在布局本身中为其设置属性。在每页(而不是布局本身)的基础上设置 'security' 属性。

所以你的布局顶部看起来像:

name="Master Layout"
description = "Master layout for almost all frontend pages."


[session]
==

<!DOCTYPE html>
<html lang="en">
<head>
.....

你的页面顶部看起来像:

title = "Restricted Page"
url = "/classified"
layout = "master"

[session]
security = "user"
redirect = "account"
==

<div class="container">

我一直在用,没问题。