Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A Breadcrumbs bundle for Symfony2 that utilises routes as a tree to build the breadcrumbs in order to not pollute the controller actions with repetitive breadcrumbs code.
PHP
branch: master

This branch is 1 commit ahead, 18 commits behind xi-project:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
Controller
DependencyInjection
EventListener
Model
Resources
Service
Tests
Twig/Extension
.gitignore
.travis.yml
LICENSE
README.md
XiBreadcrumbsBundle.php
composer.json

README.md

xi-bundle-breadcrumbs

A Breadcrumbs bundle for Symfony2.

This is different from other breadcrumb bundles, because it utilizes routes
as a tree to build the breadcrumbs in order to not pollute the controller
actions with repetitive breadcrumbs code.

Build Status

Design goals

  • Implement breadcrumbs with configurable and internationalised labels and urls
  • Keep it DRY: Do not repeat breadcrumbs code for the same page in several controller actions
  • Avoid using annotations either
  • Allow cyclical loops on breadcrumb hierarchy and handle it intelligently

Installing

'deps' file

[XiBreadcrumbsBundle]
    git=http://github.com/xi-project/xi-bundle-breadcrumbs.git
    target=/bundles/Xi/Bundle/BreadcrumbsBundle
    version=origin/master

Version declaration is optional, but recommended for Symfony 2.0.x as the master branch
will be for Symfony 2.1, which uses composer instead of deps.

autoload.php file

<?php
    'Xi\Bundle'        => __DIR__.'/../vendor/bundles',
?>

appKernel.php -file

<?php
    new Xi\Bundle\BreadcrumbsBundle\XiBreadcrumbsBundle(),
?>

Usage

Basic usage

Add {{ xi_breadcrumbs() }} into your template and add parent and label into your route defaults.
Label is optional, and defaults to the route name.

root:
    pattern:   /
    defaults:
        label: "home"

foo:
    pattern:   /foo
    defaults:
        parent: "root"

bar:
    pattern:   /foo/bar/{slug}
    defaults:
        label: "bar {slug}"
        parent: "foo"

Parent is the name of the parent route. Label can have placeholder values between braces, as shown
below with {slug}. Note that child routes should have all the placeholders available that their parents
will use – otherwise the placeholders will be stripped from the label.

Internationalised routes

For internationalised routes using BesimpleI18nRoutingBundle, use a similar array of locales as in the locales option.

xi_service:
    locales:
        en: /service
        fi: /palvelu
    defaults:
        label:
            en: "Services"
            fi: "Palvelut"

More examples

For more usage examples, see the Yaml files at Tests/Fixtures directory.

Something went wrong with that request. Please try again.