承接 thedeathvm/breadcrumbs 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thedeathvm/breadcrumbs

最新稳定版本:1.0.0

Composer 安装命令:

composer require thedeathvm/breadcrumbs

包简介

Phalcon PHP v5.8 breadcrumbs work with PHP > 8.0 author by sergeyklay/breadcrumbs

README 文档

README

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 thedeathvm/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

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-09-17