xi / breadcrumbs-bundle
Xi 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.
Installs: 3 170
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 13
Open Issues: 8
Type:symfony-bundle
Requires
- symfony/framework-bundle: 2.1.*
- symfony/locale: 2.1.*
- symfony/twig-bundle: 2.1.*
- symfony/yaml: 2.1.*
Requires (Dev)
- besimple/i18n-routing-bundle: 2.1.*@dev
- symfony/browser-kit: 2.1.*
- symfony/class-loader: 2.1.*
- symfony/css-selector: 2.1.*
- symfony/finder: 2.1.*
- symfony/form: 2.1.*
Suggests
- besimple/i18n-routing-bundle: Enables internationalised routes and breadcrumbs.
This package is not auto-updated.
Last update: 2024-12-21 14:12:33 UTC
README
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.
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
Add bundle to composer.json
"require": {
# ..
"xi/breadcrumbs-bundle": ">=2.1"
# ..
}
Add bundle to AppKernel.php
public function registerBundles() { $bundles = array( ... 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.