vaibhavpandeyvpz / pimple-breadcrumbs
Easy breadcrumbs navigation for Pimple powered apps, tested with Silex.
1.0.1
2016-09-15 08:20 UTC
Requires
- php: >=5.4.0
- pimple/pimple: ~3.0
This package is auto-updated.
Last update: 2024-10-06 11:29:37 UTC
README
Easy breadcrumbs navigation for Pimple powered apps, tested with Silex.
Install
composer require vaibhavpandeyvpz/pimple-breadcrumbs
Usage
<?php $app = new Pimple\Container(); // OR $app = new Silex\Application(); $app->register(new Pimple\Breadcrumbs\BreadcrumbsServiceProvider());
In your twig
templates, you can render items as follows (uses Bootstrap):
<ol class="breadcrumb"> {% for item in app.breadcrumbs.items() %} {% if item.route is null or loop.last %} <li class="active">{{ item.text|trans }}</li> {% else %} <li><a href="{{ path(item.route, item.params) }}">{{ item.text|trans }}</a></li> {% endif %} {% endfor %} </ol>
Helper
<?php use Pimple\Breadcrumbs\BreadcrumbsTrait; use Silex\Application as Silex; class Application extends Silex { use BreadcrumbsTrait; } $app = new Application(); $app->register(new Pimple\Breadcrumbs\BreadcrumbsServiceProvider()); $app->addBreadcrumbItem('link_text', 'link_route', ['id' => 1]);
License
See LICENSE.md file.