2017 © Pedro Peláez
 

library puja-breadcrumb

Puja-Breadcrumb is a simple class to manage the breadcrumbs

image

jinnguyen/puja-breadcrumb

Puja-Breadcrumb is a simple class to manage the breadcrumbs

  • Sunday, January 8, 2017
  • by jinnguyen
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

puja-breadcrumb

Puja-Breadcrumb is a simple class to manage the breadcrumbs, (*1)

Installation

Just run this on the command line:, (*2)

composer require jinnguyen/puja-breadcrumb

Usage

include '/path/to/vendor/autoload.php';
use Puja\Breadcrumb\Breadcrumb;

Examples:

Simple, (*3)

$breadcrumb = new Breadcrumb;
$breadcrumb->add('Subpage 2', '/subpage2');
echo $breadcrumb->render();

new breadcrumb with a array, (*4)

$breadcrumb = new Breadcrumb(array(
    array('title' => 'Home', 'link' => '/'),
    array('title' => 'Page', 'link' => '/page'),
    array('title' => 'Subpage', 'link' => '/subpage/?a=5&b[]=7&b[]=8'),
));
$breadcrumb->add('Subpage 2', '/subpage2');
echo $breadcrumb->render();

The rest of the documentation will assume you have a $breadcrumb instance on which you are making calls., (*5)

Adding a crumb

$breadcrumb->add('Home', '/');

Delete all crumb

$breadcrumb->deleteAll();

Delete last crumb

$breadcrumb->deleteLastItem();

Count breadcrumb elements

$breadcrumb->count();

Check empty

$breadcrumb->isEmpty(); // same with $breadcrumb->count() == 0

Get data:

$breadcrumb->getData(); // get all breadcrumb nodes

First and Last CSS classes

    
  • Home
  • // First Breadcrumb element
  • Page
  • Subpage
  • Subpage 2
  • // Last Breadcrumb Element

The first/last css classes are the class of first/last Breadcrumb element, (*6)

$breadcrumb->setFirstCssClassName($className);
$breadcrumb->setLastCssClassName($className);

The Element

The default breadcrumb element is <li class="{FirstLastCss}">%s{Divider}</li>. To change it, use the setElement method like so:, (*7)

$breadcrumb->setElement('<span class="{FirstLastCss}">%s{Divider}</span>');

Note:, (*8)

"%s" is required for Breadcrumb::$element
{FirstLastCss}: will be replaced by Breadcrumb::$firstCssClassName for first element and Breadcrumb::$lastCssClassName for last element
{Divider}: will be replaced by Breadcrumb::$divider

The List Element

The default list element used to wrap the breadcrumbs, is <ul>%s</ul>. To change it, use the setListElement method like so:, (*9)

$breadcrumbs->setListElement('<ol class="ol-breadcrumb">%s</ol>');

Note:, (*10)

"%s" is required for Breadcrumb::$listElement

Divider

The default breadcrumb divider is `` (empty). This will be replace to placeholder {Divider} in property Breadcrumb::$element. If you'd like to change it to, for example, /, you can just do:, (*11)

$breadcrumb->setDivider('/');

Output

Finally, when you actually want to display your breadcrumbs, all you need to do is call the render() method on the instance:, (*12)

echo $breadcrumb->render();

Note that by default crumb titles are rendered with escaping HTML characters, if you'd like to ignore it just do like so:, (*13)

$breadcrumb->setSafeHtml(false);

The Versions

08/01 2017

dev-master

9999999-dev

Puja-Breadcrumb is a simple class to manage the breadcrumbs

  Sources   Download

Apache License 2.0

by Jin Nguyen

breadcrumb puja

08/01 2017

v1.0.0

1.0.0.0

Puja-Breadcrumb is a simple class to manage the breadcrumbs

  Sources   Download

Apache License 2.0

by Jin Nguyen

breadcrumb puja