Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sergeyklay/breadcrumbs
Powerful and flexible component for building site breadcrumbs.
https://github.com/sergeyklay/breadcrumbs
breadcrumbs crumbs phalcon php
Last synced: 3 months ago
JSON representation
Powerful and flexible component for building site breadcrumbs.
- Host: GitHub
- URL: https://github.com/sergeyklay/breadcrumbs
- Owner: sergeyklay
- License: other
- Created: 2016-02-21T15:59:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-16T15:04:19.000Z (over 3 years ago)
- Last Synced: 2024-10-20T06:50:32.165Z (3 months ago)
- Topics: breadcrumbs, crumbs, phalcon, php
- Language: PHP
- Homepage: https://packagist.org/packages/sergeyklay/breadcrumbs
- Size: 104 KB
- Stars: 40
- Watchers: 8
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-phalcon - Breadcrumbs - Powerful and flexible component for building site breadcrumbs in Phalcon 2+. (Miscellaneous)
README
# Phalcon Breadcrumbs [![Build Status][:travis-badge:]][:travis-url:]
![Breadcrumbs Screenshot][:screenshot:]
Phalcon Breadcrumbs is a powerful and flexible component for building site breadcrumbs.
You can adapt it to your own needs or improve it if you want.Please write us if you have any feedback.
Thanks!
## NOTE
The `master` branch will always contain the latest stable version. If you wish
to check older versions or newer ones currently under development, please
switch to the relevant branch/tag.## Getting Started
### Requirements
To use this component, you need at least:
* [Composer][:composer:]
* PHP >= 5.5
* [Phalcon Framework release][:phalcon:] extension enabled >= 2.x < 4.x**NOTE:** Support for legacy PHP versions (down to 7.0) is provided on a best-effort basis.
### Installing
```sh
$ composer require sergeyklay/breadcrumbs
```### Define your breadcrumbs
We recommend registering it with your application's services for even easier use:
```php
setShared('breadcrumbs', function () {
return new Breadcrumbs;
});
```**Adding a crumb with a link:**
```php
breadcrumbs->add('Home', '/');
```**Adding a crumb without a link (normally the last one):**
```php
breadcrumbs->add('User', null, ['linked' => false]);
```**Output crumbs:**
Php Engine
```html
```Volt Engine
```volt
```**Change crumb separator:**
```php
breadcrumbs->setSeparator(' » ');
```**Make The last element is always not a link:**
```php
breadcrumbs->setLastNotLinked(true);
```**Delete a crumb (by url):**
```php
breadcrumbs->remove('/admin/user/create');// remove a crumb without an url
$this->breadcrumbs->remove(null);
```**Update an existing crumb:**
```php
breadcrumbs->update('/admin/user/remove', ['label' => 'Remove']);
```**Count crumbs:**
```php
breadcrumbs->count();
```**Sets rendering template:**
```php
breadcrumbs->setTemplate(
'
'
'' // first icon
);
```
**Multi-language support:**
```php
'Home',
'crumb-user' => 'User',
'crumb-settings' => 'Settings',
'crumb-profile' => 'Profile',
];
// Initialize the Translate adapter.
$di->setShared('translate', function () use ($messages) {
return new Translator(['content' => $messages]);
});
// Initialize the Breadcrumbs component.
$di->setShared('breadcrumbs', function () {
return new Breadcrumbs;
});
```
**Errors logging:**
```php
setShared('logger', function ($filename = null, $format = null) use ($config) {
$formatter = new FormatterLine($config->get('logger')->format, $config->get('logger')->date);
$logger = new FileLogger($config->get('logger')->path . $config->get('logger')->filename);
$logger->setFormatter($formatter);
$logger->setLogLevel($config->get('logger')->logLevel);
return $logger;
});
// Initialize the Breadcrumbs component.
$di->setShared('breadcrumbs', function () {
return new Breadcrumbs;
});
```
### Events
```php
setShared('eventsManager', function () {
return new EventsManager;
});
// Initialize the Breadcrumbs component.
$di->setShared('breadcrumbs', function () use ($di) {
$manager = $di->getShared('eventsManager');
$manager->attach('breadcrumbs', function ($event, $connection) {
// We stop the event if it is cancelable
if ($event->isCancelable()) {
// Stop the event, so other listeners will not be notified about this
$event->stop();
}
// Receiving the data from the event context
print_r($event->getData());
});
$breadcrumbs = new Breadcrumbs;
$breadcrumbs->setEventsManager($manager);
return $breadcrumbs;
});
```
Available events:
```
breadcrumbs:beforeAdd
breadcrumbs:afterAdd
breadcrumbs:beforeOutput
breadcrumbs:afterOutput
breadcrumbs:beforeTranslate
breadcrumbs:afterTranslate
breadcrumbs:beforeLogging
breadcrumbs:afterLogging
breadcrumbs:beforeRemove
breadcrumbs:afterRemove
breadcrumbs:beforeUpdate
breadcrumbs:afterUpdate
breadcrumbs:beforeSetTemplate
breadcrumbs:afterSetTemplate
```
## Copyright
Phalcon Breadcrumbs is open-sourced software licensed under the [New BSD License][:license:].
© Serghei Iakovlev
[:composer:]: https://getcomposer.org/
[:phalcon:]: https://github.com/sergeyklay/cphalcon/releases
[:license:]: https://github.com/sergeyklay/breadcrumbs/blob/master/LICENSE.txt
[:screenshot:]: https://github.com/sergeyklay/breadcrumbs/blob/master/docs/breadcrumbs.png
[:travis-url:]: https://travis-ci.com/sergeyklay/breadcrumbs
[:travis-badge:]: https://travis-ci.com/sergeyklay/breadcrumbs.svg?branch=master