Download the PHP package whiteoctober/breadcrumbs-bundle without Composer
On this page you can find all versions of the php package whiteoctober/breadcrumbs-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download whiteoctober/breadcrumbs-bundle
More information about whiteoctober/breadcrumbs-bundle
Files in whiteoctober/breadcrumbs-bundle
Package breadcrumbs-bundle
Short Description A small breadcrumbs bundle for Symfony2
License MIT
Homepage https://github.com/whiteoctober/BreadcrumbsBundle
Informations about the package breadcrumbs-bundle
WARNING: This project is no longer maintained. If you are using it with Symfony >= 4.3, you may want to use this fork instead.
Installation
-
Configure templating for your application if you haven't already. For example:
-
Install this bundle using Composer:
-
Add this bundle to your application's kernel:
If you're using Symfony 4, this step will be done for you by Symfony Flex.
- Configure the bundle in your config:
That's it for basic configuration. For more options check the Configuration section.
Usage
In your application controller methods:
For Symfony 4, don't retrieve the service via get
, instead use
dependency injection:
Then, in your template:
The last item in the breadcrumbs collection will automatically be rendered
as plain text rather than a <a>...</a>
tag.
The addItem()
method adds an item to the end of the breadcrumbs collection.
You can use the prependItem()
method to add an item to the beginning of
the breadcrumbs collection. This is handy when used in conjunction with
hierarchical data (e.g. Doctrine Nested-Set). This example uses categories in
a product catalog:
If you do not want to generate a URL manually, you can easily add breadcrumb items
passing only the route name with any required parameters, using the addRouteItem()
and prependRouteItem()
methods:
Configuration
The following default parameters can be overriden in your config.yml
or similar:
These can also be passed as parameters in the view when rendering the breadcrumbs - for example:
NOTE: If you need more than one set of breadcrumbs on the same page you can use namespaces. By default, breadcrumbs use the
default
namespace, but you can add more. To add breadcrumbs to your custom namespace useaddNamespaceItem
/prependNamespaceItem
oraddNamespaceRouteItem
/prependNamespaceRouteItem
methods respectively, for example:
Then to render the subsection
breadcrumbs in your templates, specify this namespace in the options:
Advanced Usage
You can add a whole array of objects at once
Example:
You can also add a tree path
NOTE: You can use
addNamespaceObjectArray
andaddNamespaceObjectTree
respectively for work with multiple breadcrumbs on the same page.
Overriding the template
There are two methods for doing this.
-
You can override the template used by copying the
Resources/views/microdata.html.twig
file out of the bundle and placing it intoapp/Resources/WhiteOctoberBreadcrumbsBundle/views
, then customising as you see fit. Check the Overriding bundle templates documentation section for more information. - Use the
viewTemplate
configuration parameter:
NOTE: If you want to use the JSON-LD format, there's already an existing template at
WhiteOctoberBreadcrumbsBundle::json-ld.html.twig
. Just set this template as the value forviewTemplate
either in your Twig function call (see Step 2 above) or in your bundle configuration.
(This project was originally at https://github.com/whiteoctober/BreadcrumbsBundle)
All versions of breadcrumbs-bundle with dependencies
symfony/framework-bundle Version ~2.0|~3.0|^4.0
symfony/templating Version ~2.7|~3.0|^4.0