fosforus/authblock-shortcode

创建一个短代码块,用于测试用户是否登录,并按需渲染内容。

安装次数: 8

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:silverstripe-vendormodule

4.0.1 2018-12-11 02:26 UTC

This package is auto-updated.

Last update: 2024-09-11 15:24:03 UTC


README

Version License

需求

  • SilverStripe CMS 4.2+

安装

composer require fosforus/authblock-shortcode

使用

在任何短代码启用的编辑字段(HTMLEditor等)中,将此短代码放置在您希望基于用户登录状态“门控”的内容块周围。例如:仅向当前登录的用户显示特定内容块

[authblock auth="true"]Hello, member![/authblock]

仅向未登录(匿名)用户显示内容

[authblock auth="false"]You may log in <a href="/Security/login">here</a>.[/authblock]

注意,由于 短代码嵌套限制,您不能在 authblock 中放置短代码。对于更复杂的情况,请考虑在您的Controller中创建自定义模板变量。

您还可以设置单个权限以进一步限定认证检查,例如。

[authblock auth="true" perm="CMS_ACCESS"]Edit the site <a href="/admin/pages">here</a>.[/authblock]

在这种情况下,如果用户未通过网站认证或用户没有通过CMS_ACCESS_*权限访问任何CMS,则块内容不会显示。再次提醒,对于更复杂的权限检查,扩展您的Controller。