Overview

Namespaces

  • Sleepy
  • Module
    • Authentication
    • CSV
    • DB
    • FormBuilder
    • FSDB
    • IP2Country
    • Mailer
    • MobiDetect
    • Navigation
    • StaticCache
  • PHP

Classes

  • Builder
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Builder

Creates a Navigation UL based on a JSON file

Uses JSON to structure navigation pages and attributes. It can detect what page is active and assign classes to them for special treatment.

Usage

$topNavData = '{
   "pages": [
     {
       "title": "Nav 1",
       "link": "/nav1/"
     }, {
       "title": "Nav 2",
       "link": "/nav2/",
       "pages": [
         {
           "title": "Subnav 1",
           "link": "/downloads/fpo.pdf",
           "target": "_blank"
         }
       ]
     }
   ]
 }';

 $topNav = new \Module\Navigation\Builder($topNavData);

 // In body somewhere...
 <nav class="top">
   <?= $topNav->show(); ?>
 </nav>

Changelog

Version 1.4

  • Now automatically sets $_SERVER['SCRIPT_NAME'] as current page
  • Added multiple hook points for manipulating navigations

Version 1.2

  • Added a track parameter
Namespace: Module\Navigation
License: http://opensource.org/licenses/MIT
Author: Jaime A. Rodriguez hi.i.am.jaime@gmail.com
Version: 1.1
Date: June 16, 2014
Located at class.navigation.php
Methods summary
public
# __construct( string $json = '' )

Constructor

Constructor

Parameters

$json
json data containing the Navigation data
private integer
# hasActive( object $page )

Is this page or its children an active page?

Is this page or its children an active page?

Parameters

$page
An object containing page data

Returns

integer
0=none;1=active;2=activeChild

Private

private string
# renderNav( object $pages, $class = "" )

Renders the $pages as an unordered list

Renders the $pages as an unordered list

Parameters

$pages
the page data
$class

Returns

string
The string containing the unordered list
public string
# show( $class = "" )

Renders the Navigation

Renders the Navigation

Returns

string
The rendered navigation
public
# setCurrent( string $string )

Sets the current page search string

Sets the current page search string

Parameters

$string
A string used to determine if a page is current
Properties summary
private $current

string Use this string to determine currently active page

string Use this string to determine currently active page

Private

#
private $data

mixed Navigation data

mixed Navigation data

#
private integer $_level

mixed Level

mixed Level

# 0
sleepyMUSTACHE v.0.8 API documentation generated by ApiGen