Download the PHP package mhujer/breadcrumbs-bundle without Composer
On this page you can find all versions of the php package mhujer/breadcrumbs-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mhujer/breadcrumbs-bundle
More information about mhujer/breadcrumbs-bundle
Files in mhujer/breadcrumbs-bundle
Package breadcrumbs-bundle
Short Description Breadcrumbs bundle for Symfony
License MIT
Homepage https://github.com/mhujer/BreadcrumbsBundle
Informations about the package breadcrumbs-bundle
This is a fork of whiteoctober/BreadcrumbsBundle maintained for newer Symfony versions. See whiteoctober/BreadcrumbsBundle#106.
Installation
- Install this bundle using Composer:
If you're using Symfony Flex, the following steps will be done automatically.
-
Enable the bundle by adding it to the list of registered bundles in the
config/bundles.php
file of your project: - Configure the bundle in
config/packages/white_october_breadcrumbs.yaml
:
That's it for basic configuration. For more options check the Configuration section.
Usage
In your application controller methods:
It is preferable, that you don't retrieve the service via get
. Use
dependency injection instead:
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 overridden in your config/packages/white_october_breadcrumbs.yaml
:
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 into<your-project>/templates/bundles/WhiteOctoberBreadcrumbsBundle
, 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
@WhiteOctoberBreadcrumbs/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.
Contributing
We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).
If you'd like to contribute code but aren't sure what, the issues list is a good place to start. If you're a first-time code contributor, you may find Github's guide to forking projects helpful.
All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our code of conduct.
All versions of breadcrumbs-bundle with dependencies
symfony/framework-bundle Version ^5.4|^6.0|^7.0
symfony/translation-contracts Version ^1.1|^2.0|^3.0
symfony/twig-bundle Version ^5.4|^6.0|^7.0
twig/twig Version ^1.38.1|^2.7.1|^3.0