famelo/navigation

There is no license information available for the latest version (dev-master) of this package.

Installs: 142

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:typo3-flow-package

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

This package is auto-updated.

Last update: 2024-12-05 18:33:28 UTC


README

This package uses a combination of Routes.yaml and Policy.yaml to generate a menu for you :)

-
  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

That routes will be parsed based on the paths into:

Home
Products
  - Foo

Now let's render a menu from that information:

{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>

Something you don't see, which happens in the background is, that each NavigationItem is checked through the Policy.yaml if the current user has access to it. So, if you add a Policy.yaml like this:

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

roles:
  Administrator: []

acls:
  Administrator:
    methods:
      Products: GRANT

Only the Logged in Administrator will see the Products NavigationItems :)