famelo/navigation

此包最新版本(dev-master)没有提供许可证信息。

安装: 142

依赖项: 1

建议: 0

安全性: 0

星星: 0

关注者: 3

分支: 0

开放性问题: 0

类型:typo3-flow-package

dev-master 2014-02-28 10:34 UTC

This package is auto-updated.

Last update: 2024-09-05 18:02:08 UTC


README

此包结合使用 Routes.yaml 和 Policy.yaml 来为您生成菜单 :)

-
  name: 'Home'
  uriPattern: 'home'
  navigation: 'Home'
  defaults:
    '@format': 'html'
    '@action':     'index'
    '@controller': 'Standard'
    '@package': 'My.Package'
  appendExceedingArguments: true

-
  name: 'Products'
  uriPattern: 'products'
  navigation: 'Products'
  defaults:
    '@format': 'html'
    '@action':     'index'
    '@controller': 'Products'
    '@package': 'My.Package'
  appendExceedingArguments: true

-
  name: 'Product in Foo Category'
  uriPattern: 'products/foo'
  navigation: 'Foo'
  defaults:
    '@format': 'html'
    '@action':     'foo'
    '@controller': 'Products'
    '@package': 'My.Package'
  appendExceedingArguments: true

这些路由将根据路径进行解析

Home
Products
  - Foo

现在,让我们使用这些信息渲染一个菜单

{namespace n=Famelo\Navigation\ViewHelpers}
<ul class="navigation">
<n:navigation as="items">
<f:for each="{items}" as="item">
  <li>
      <n:action actionConfiguration="{item}">{item.label}</n:action>
      <f:if condition="{item.children}">
        <ul>
        <f:for each="{item.children}" as="child">
          <li>
              <n:action actionConfiguration="{child}">{child.label}</n:action>
          </li>
        </f:for>
        </ul>
      </f:if>
  </li>
</f:for>
</n:navigation>
</ul>

在后台发生的一些您看不到的操作是,每个 NavigationItem 都会通过 Policy.yaml 检查当前用户是否有权限访问。所以,如果您添加一个如下的 Policy.yaml

resources:
  methods:
    Products: 'method(My\Package\Controller\ProductsController->.*Action())'

roles:
  Administrator: []

acls:
  Administrator:
    methods:
      Products: GRANT

只有登录的管理员会看到“产品”导航项 :)