Powerful and flexible component for building site breadcrumbs.

Overview

Phalcon Breadcrumbs Build Status

Breadcrumbs 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:

NOTE: Support for legacy PHP versions (down to 7.0) is provided on a best-effort basis.

Installing

$ composer require sergeyklay/breadcrumbs

Define your breadcrumbs

We recommend registering it with your application's services for even easier use:

<?php

use Phalcon\Breadcrumbs;

// Initialize the Breadcrumbs component.
$di->setShared('breadcrumbs', function () {
    return new Breadcrumbs;
});

Adding a crumb with a link:

<?php

$this->breadcrumbs->add('Home', '/');

Adding a crumb without a link (normally the last one):

<?php

$this->breadcrumbs->add('User', null, ['linked' => false]);

Output crumbs:

Php Engine

<ol class="breadcrumb">
    <?php $this->breadcrumbs->output(); ?>
</ol>

Volt Engine

<ol class="breadcrumb">
  {{ breadcrumbs.output() }}
</ol>

Change crumb separator:

<?php

$this->breadcrumbs->setSeparator(' &raquo; ');

Make The last element is always not a link:

<?php

$this->breadcrumbs->setLastNotLinked(true);

Delete a crumb (by url):

<?php

$this->breadcrumbs->remove('/admin/user/create');

// remove a crumb without an url
$this->breadcrumbs->remove(null);

Update an existing crumb:

<?php

$this->breadcrumbs->update('/admin/user/remove', ['label' => '<strong class="red">Remove</strong>']);

Count crumbs:

<?php

$this->breadcrumbs->count();

Sets rendering template:

<?php

$this->breadcrumbs->setTemplate(
    '<li><a href="{{link}}">{{icon}}{{label}}</a></li>', // linked
    '<li class="active">{{icon}}{{label}}</li>',         // not linked
    '<i class="fa fa-dashboard"></i>'                    // first icon
);

Multi-language support:

<?php

use Phalcon\Translate\Adapter\NativeArray as Translator;
use Phalcon\Breadcrumbs;

$messages = [
    'crumb-home'     => '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

use Phalcon\Logger\Formatter\Line as FormatterLine;
use Phalcon\Logger\Adapter\File as FileLogger;
use Phalcon\Breadcrumbs;

/**
 * Initialize the Logger.
 *
 * @var $config array
 * @var $di \Phalcon\Di
 */
$di->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

use Phalcon\Breadcrumbs;
use Phalcon\Events\Manager as EventsManager;

// Initialize the Events Manager.
$di->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. © Serghei Iakovlev

Comments
  • When will the next version be released,please

    When will the next version be released,please

    Our project will be upgraded to php7.3, and phalcon extension will also be passively upgraded to 4.0, but there is no breadcrumbs package available, so please ask when you will update

    opened by BinChengZhao 5
  • Phalcon 4 compatibility

    Phalcon 4 compatibility

    Already required compatibility with version 4. Made some changes.

    @sergeyklay what will you do? Will you make tag v2.x.x or will you create a separate repository?

    opened by sinbadxiii 3
  • Last element is always not a link

    Last element is always not a link

    When creating a crumb path, an example:

    Home / News / News1

    You can set the initialization in NewsController:

    public function initialize()
         {
             parent::initialize();
             $this->breadcrumbs->add('News', '/news');
         }
    
     public function showAction()
        {
            ...
            $this->breadcrumbs->add(
                'News1', '/news/news1'
            );
            ...
        }
    

    if this is just an indexAction(), then when the method setLastNotLinked flag is set (true), the link will not be clickable, but if we showAction() the news1, then the reference to the crumb "News" will already be clickable, and the news1 itself will not be clickable

    opened by sinbadxiii 2
  • When browsing phalcon breadcrumb in other than defult module Error

    When browsing phalcon breadcrumb in other than defult module Error

    Uncaught Error: Class 'Phalcon\Breadcrumbs' not found in F:\htdocs\phalcon\app\config\services_web.php for module backend. For module frontend no error.

    opened by mdmamunhasan 1
  • Change CHANGELOG [ci skip]

    Change CHANGELOG [ci skip]

    Hello!

    • Type: documentation
    • Link to issue: -

    In raising this pull request, I confirm the following:

    • [x] I have read and understood the Contributing Guidelines
    • [x] I have checked that another pull request for this purpose does not exist
    • [ ] I wrote some tests for this PR

    Small description of change: Change CHANGELOG.md

    Thanks

    opened by sergeysviridenko 1
  • Delete ignore platform

    Delete ignore platform

    Hello!

    • Type: bug fix
    • Link to issue: -

    In raising this pull request, I confirm the following (please check boxes):

    • [x] I have read and understood the Contributing Guidelines
    • [x] I have checked that another pull request for this purpose does not exist
    • [ ] I wrote some tests for this PR

    Small description of change: Delete ignore platform

    Thanks

    opened by sergeysviridenko 1
  • Error with two or more null linked

    Error with two or more null linked

    Hello, When I try to put two or more nulls linked, breadcrumbs only show the last one. In this I can't see $nameEvent but I can see $city because is the last one with no linked. My code:

            // breadcrumbs
            $this->Breadcrumbs->add('Home', '/');
            $this->Breadcrumbs->add('Eventos', '/eventos');
            $this->Breadcrumbs->add($nameEvent, null, ['linked' => false]);
            $this->Breadcrumbs->add($city, null, ['linked' => false]);
            $this->Breadcrumbs->add($evento->nombre_evento, '/eventos/' . $evento->slug);
    

    Any ideas? Thank you!

    bug 
    opened by davidcm86 0
  • namspace Phalcon\Breadcrumbs заменить Phalcon\

    namspace Phalcon\Breadcrumbs заменить Phalcon\

    @sergeyklay я напишу на русском, чтобы точнее выразить мысль)

    Я хочу доработать хлебные крошки, добавив возможность внедрить микроразметку, той же Scheme.org, например.

    Для этого мне нужно добавить папку Microdata с адаптерами микроразметки и использовать их уже непосредственно в классе Breadcrumbs, но проблема в том, что namespace у пакета идет Phalcon, что затрудняет использовать что-то внутри пакета, помимо главного класса.

    Как временный костыль, чтобы иметь возможность доработать пакет я в composer.json прописал

    "autoload": {
            "psr-4": {
                  ...
                "Phalcon\\Breadcrumbs\\": "vendor/sergeyklay/breadcrumbs/src/"
            }
        }
    

    Вот хотел уточнить не планируется ли изменить namespace пакета на Phalcon\Breadcrumbs или может как-то по-другому выйти из такой ситуации?

    opened by sinbadxiii 4
Releases(v1.4.2)
Site Web pour un site de conciergerie d'entreprise

DATE DE CREATION : 30 novembre 2021 • Développement d'un site Web pour une entreprise de conciergerie pour entreprise, une interface pour les dirigea

Tiffany Dufetel 1 Jan 10, 2022
Yclas Self Hosted is a powerful script that can transform any domain into a fully customizable classifieds site within a few seconds.

Yclas 4.4.0. Description Yclas self-hosted is a powerful script that can transform any domain into a fully customizable classifieds site within a few

Yclas 299 May 29, 2022
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.

TARS - A Linux Foundation Project TARS Foundation Official Website TARS Project Official Website WeChat Group: TARS01 WeChat Offical Account: TarsClou

THE TARS FOUNDATION PROJECTS 9.6k Jan 1, 2023
Admidio is a free open source user management system for websites of organizations and groups. The system has a flexible role model so that it’s possible to reflect the structure and permissions of your organization.

Admidio Admidio is a free open source user management system for websites of organizations and groups. The system has a flexible role model so that it

Admidio 212 Dec 30, 2022
A robust and flexible way to add double-opt-in (DOI) to any form in Mautic

Mautic double-opt-in (DOI) plugin Adds a robust and flexible way to add a double-opt-in process (DOI) to any form in Mautic. What is the plugin for? I

Content Optimizer GmbH 11 Dec 29, 2022
WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate is simply a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate 1.7k Dec 24, 2022
An application for building and managing Phars.

An application for building and managing Phars.

Box Project 1.2k Nov 9, 2022
Very flexible git hook manager for php developers

CaptainHook CaptainHook is an easy to use and very flexible git hook library for php developers. It enables you to configure your git hook actions in

CaptainHook 812 Dec 30, 2022
Drupal Composer Scaffold - A flexible Composer project scaffold builder

This project provides a composer plugin for placing scaffold files (like index.php, update.php, …) from the drupal/core project into their desired location inside the web root. Only individual files may be scaffolded with this plugin.

Drupal 44 Sep 22, 2022
A minimal library that defines primitive building blocks of PHP code.

Jungi Common A minimal library that defines primitive building blocks of PHP code. It combines the advantages of functional and object-oriented progra

Piotr Kugla 28 Jul 15, 2022
A minimal library that defines primitive building blocks of PHP code.

A minimal library that defines primitive building blocks of PHP code. It combines the advantages of functional and object-oriented programming. All of this makes code easier to understand and less prone to errors.

Jungi 28 Jul 15, 2022
Samsui is a factory library for building PHP objects useful for setting up test data in your applications.

#Samsui Samsui is a factory library for building PHP objects useful for setting up test data in your applications. It is mainly inspired by Rosie for

Sam Yong 31 Nov 11, 2020
A trait to make building your own custom Laravel Model Searches a lot easier.

BrekiTomasson\LaravelModelFinder A simple trait that makes building your own custom Laravel Model Searches a lot easier and safer. It ensures that you

Breki Tomasson 3 Nov 27, 2022
❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

❄️ Magento 2 Snowflake module allow you to add snow and even more on your site and make winter fun.

OpenGento 6 Apr 30, 2022
Orangescrum is a simple yet powerful free and open source project management software that helps team to organize their tasks, projects and deliver more.

Free, open source Project Management software Introduction Orangescrum is the simple yet powerful free and open source project management software tha

Orangescrum 110 Dec 30, 2022
Adds a header to every response to try and twart Google's usage of your site in it's FLoC tracking method.

Laravel No FLoC This package will add the Permissions-Policy: interest-cohort=() to try and twart Google's usage of your site in it's FLoC tracking me

Jean-Philippe Murray 11 Jul 14, 2022
This shell script and PHP file create a browseable HTML site from the Zig standard library source.

Browseable Zig standard library This shell script and PHP file create a browseable HTML site from the Zig standard library source. The idea is to inve

Dave Gauer 3 Mar 20, 2022
Arc meta - Textpattern plugin for meta tags to improve site SEO and social marketing.

arc_meta A Textpattern plugin for meta tags to improve site SEO and social marketing. arc_meta adds meta fields to your article, section and category

Andy Carter 3 Jan 20, 2017