GithubHelp home page GithubHelp logo

akomm / spiffy-navigation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spiffyjr/spiffy-navigation

0.0 0.0 0.0 460 KB

A ZF2 module designed as a replacement for Zend\Navigation.

PHP 96.65% HTML 3.35%

spiffy-navigation's Introduction

SpiffyNavigation Module for Zend Framework 2

SpiffyNavigation is a navigation module for ZF2 intended to be a replacement for Zend\Navigation when ZF3 is able to break BC.

Project Status

Master Branch Build Status Coverage Status

Requirements

Installation

Installation of SpiffyNavigation uses composer. For composer documentation, please refer to getcomposer.org.

Installation steps

  1. cd my/project/directory

  2. create a composer.json file with following contents:

    {
        "require": {
            "spiffy/spiffy-navigation": "dev-master"
        }
    }
  3. install composer via curl -s http://getcomposer.org/installer | php (on windows, download http://getcomposer.org/installer and execute it with PHP)

  4. run php composer.phar install

  5. open my/project/directory/configs/application.config.php and add the following key to your modules:

    'SpiffyNavigation',

Providers

Providers let you create your navigation containers from various sources. The following providers are included out of the box:

  • array: builds a container from an array.
  • config: builds a container from a file using Zend\Config.
  • json: builds a container from a json string.

Creating containers

Creating navigation containers is done via the module configuration using the spiffy_navigation key. The containers array can take two types of values: a string and an array. If you pass a string the container will be created from a provider matching the name if it exists, pulled from the service manager or instantiated directly. If you pass an array the container is built using the ContainerFactory::create() method.

<?php

// module.config.php
return array(
    'spiffy_navigation' => array(
        'containers' => array(
            'default' => array(
                array(
                    'options' => array(
                        'uri' => 'http://www.github.com',
                    ),
                    'attributes' => array(
                        'class'  => 'foo',
                        'target' => '_blank',
                        'name'   => 'github'
                    )
                ),
                array(
                    'options' => array(
                        'label' => 'Home',
                        'route' => 'home',
                    ),
                    'attributes' => array(
                        'name' => 'Home'
                    )
                    'pages' => array(
                        // ...
                    )
                )
            ),

            'serviceManager' => 'My\ServiceManager\Alias',

            'class' => 'My\Class\Instantiation',

            'json_provider' => 'mynav',
        ),

        'providers' => array(
            'mynav' => array(
                'type' => 'json',
                'options' => array(
                    'json' => file_get_contents(__DIR__ . '/navigation/mynav.json')
                )
            )
        )
    )
);

Page options

  • label: The label for the element in view helpers.
  • anchor: An optional anchor to append to the uri.
  • route: The route to use for assembling the uri.
  • uri: The direct uri to use (use instead of route).
  • params: Optional params to include during route assembly.
  • query_params: Optional params to include in the query string during assembly.

Rbac specific options

  • role: required The role to use to determine if access is granted.
  • permission: required The permission to use to determine if access is granted.
  • assertion: The assertion to use to determine if access is granted.

Using the view helpers

Once you have created a container using a view helper is as simple as putting:

<?php

echo $this->helperName('containerName');

NavigationMenu

Quick Start

<?php

// in view script
echo $this->navigationMenu('containerName');

// or

echo $this->navigationMenu()->renderMenu('containerName', $options);

// or

echo $this->navigationMenu()->renderPartial('containerName', 'partialName');

Options

  • ulClass: The class to use when generating the ul.
  • minDepth: Minimum render depth.
  • maxDepth: Maximum render depth.
  • activeClass: Active class to use for the active element.

spiffy-navigation's People

Contributors

bountin avatar davidwindell avatar e-belair avatar internalsystemerror avatar localheinz avatar prolic avatar spiffyjr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.