【发布时间】:2017-09-12 05:33:52
【问题描述】:
Grav 的文档清楚地描述了how a whole page or a folder could be hidden from unregistered users。它还描述了how a whole page could be seen only by particular user groups。
但是页面的片段,比如说,我想在某些条件下显示的一些链接或私人信息呢?
好的,对于注册用户,我在Login plugin docs找到了一个sn-p:
{% if grav.user.authenticated %}
content for registered users goes here
{% endif %}
但更广泛 - 我如何根据 PHP 代码中的一些自定义逻辑显示/隐藏特定页面的 片段,即不一定与用户相关?
我正在考虑一个 twig/shortcode 插件,例如:
{% if some.custom.condition.or.PHP.function %}
hidden content goes here
{% endif %}
或
[hidden_if_something] hidden content goes here [/hidden_if_something]
但不确定应该如何实现。因此,工作示例将不胜感激。谢谢。
【问题讨论】: