简体   繁体   English

Typo3 Neos:向不同访问级别的登录用户显示不同的菜单项

[英]Typo3 Neos: show different Menu items to loggedin users of different access levels

I have created menus in Neos backend. 我已经在Neos后端创建了菜单。 Each menu node corresponds to a plugin of a controlleraction. 每个菜单节点对应一个controlleraction的插件。 These controller actions are defined in policy.yaml as resources with their flow access policy roles. 这些控制器操作在policy.yaml中定义为具有其流访问策略角色的资源。 The template for menu is defined in root.ts2 which i took a copy from Typo3.NeosDemoTypo3Org package. 菜单模板在root.ts2中定义,我从Typo3.NeosDemoTypo3Org包中获取了一个副本。

mainMenu part of root.ts2 is root.ts2的mainMenu部分是

mainMenu = Menu {
entryLevel = 1
templatePath = 'resource://ABC.Demo/Private/Templates/TypoScriptObjects/MainMenu.html'
maximumLevels = 3
site = ${site}
}

MainMenu.html is: MainMenu.html是:

<div class="collapse navbar-collapse navbar-main-collapse">
<ul class="nav nav-pills nav-justified">
<f:for each="{items}" as="item" iteration="menuItemIterator">
                    <f:then>
                            <li class="active">
                                <neos:link.node node="{item.node}">{item.label}</neos:link.node>
                            </li>
                        </f:then>
                        <f:else>
                            <li>
                                <neos:link.node node="{item.node}">{item.label}</neos:link.node>
                            </li>
                        </f:else>
                    </f:if>
                </f:for>
        </ul>
     </div>

If I use {parts.mainMenu -> f:format.raw()} in Default.html, it prints all the menu items defined at root of Neos site. 如果在Default.html中使用{parts.mainMenu-> f:format.raw()},它将打印在Neos站点根目录定义的所有菜单项。

How can i show only those menu items in main menu of webpage for which the user has access to the corresponding resource defined in policy.yaml. 我如何仅显示网页主菜单中用户有权访问policy.yaml中定义的相应资源的那些菜单项。

Can anybody give an idea, the way to achieve it. 任何人都可以提出一个想法,以及实现它的方法。

You should set the access protection on the page node. 您应该在页面节点上设置访问保护。 Currently there no interface for this yet, but you can define access roles for the nodes in the database. 当前尚无此接口,但是您可以为数据库中的节点定义访问角色。 See table: typo3_typo3cr_domain_model_nodedata field accessroles. 请参阅表:typo3_typo3cr_domain_model_nodedata字段访问权限。 It should be a serialized array of role names. 它应该是角色名称的序列化数组。 This will then correctly reflect in the menu. 然后,这将正确反映在菜单中。 And don't forget to set the TYPO3.Neos:Editor role as well otherwise editors won't be able to modify those pages. 并且不要忘记设置TYPO3.Neos:Editor角色,否则编辑者将无法修改这些页面。

It would be quite complicated to fetch the plugins from each page and do access checks against them but that could of course be another option. 从每个页面获取插件并对其进行访问检查将是相当复杂的,但这当然是另一种选择。 I cannot directly give you any hints for that thou, because the node type would be different for each page, depending on the plugin. 我不能直接为您提供任何提示,因为每个页面的节点类型会有所不同,具体取决于插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM