2017 © Pedro PelĂĄez
 

library navigation

Simple static navigation handler

image

stephanecoinon/navigation

Simple static navigation handler

  • Wednesday, July 23, 2014
  • by stephanecoinon
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Navigation Build Status

Simple handler for navigation configuration., (*1)

Installation

In your terminal, just run:, (*2)

composer require "stephanecoinon/navigation":"dev-master"

Usage

Create a single navigation


// Add this code in your controller use Coinon\Navigation\Navigation; // Describe the navigation items // Ideally, you should load this from a configuration file // Each item can define the following keys: // title: (mandatory) title to display on the link // slug: (optional) if omitted, the package will slugify the title // active: (optional) flag to say whether the item is the // currently active one, true by default // url: (optional) absolute URL or URL relative to the // base URL passed to constructor. // Using the slug by default // $navConfiguration = [ ['title' => 'Home'], ['title' => 'About us'], [ 'title' => 'Contact us', 'slug' => 'contact', // will be used for URL in this case ], ]; // The base URL in second argument is optional $navigation = new Navigation($navConfiguration, 'http://app.dev:8000'); // Flag the active item by slug $navigation->activateItem('about-us'); // then pass $navigations to your views // Add this code in your view

Create multiple navigations

Navigation can handle multiple navigations when you need them for main horizontal menu, side bar, footer navigation..., (*3)


// Add this code in your controller use Coinon\Navigation\Navigations; // note the plural // Ideally, you should load this from a configuration file $navConfiguration = [ // main navigation 'main' => [ ['title' => 'Home'], ['title' => 'About us'], ['title' => 'Contact us'], ], // footer navigation 'footer' => [ ['title' => 'Contact us'], [ 'title' => 'Twitter', 'url' => 'https://www.twitter.com/breizik29', ], ['title' => 'Facebook'], ], ]; $navigations = new Navigations($navConfiguration, 'http://app.dev:8000'); $navigations->get('main')->activateItem('contact-us'); $navigations->get('footer')->activateItem('contact-us'); // then pass $navigations to your views // Add this code in the view that displays the main navigation
    get('main')->all() as $navItem): ?>
  • isActive() ? 'class="active"' : '' ?>> =$navItem->title ?>
// You can access the footer navigation in a similar way using $navigations->get('footer')->all()

The Versions

23/07 2014

dev-master

9999999-dev https://github.com/stephanecoinon/navigation

Simple static navigation handler

  Sources   Download

MIT

The Requires

 

by Stéphane Coinon

09/07 2014

v0.1

0.1.0.0

Simple static navigation handler

  Sources   Download

The Requires

 

by Stéphane Coinon