1. Go to this page and download the library: Download xepozz/breadcrumbs-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
xepozz / breadcrumbs-bundle example snippets
use Xepozz\BreadcrumbsBundle\Model\Breadcrumbs;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class Controller extends AbstractController
{
public function action(Breadcrumbs $breadcrumbs, UrlGeneratorInterface $urlGenerator)
{
// Simple example
$breadcrumbs->addItem('Home', $urlGenerator->generate('index'));
// Example without URL
$breadcrumbs->addItem('Some text without link');
// Example with parameter injected into translation "user.profile"
$breadcrumbs->addItem('Account: %user%', '', ['%user%' => 'Username']);
}
}
use Xepozz\BreadcrumbsBundle\Model\Breadcrumbs;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class Controller extends AbstractController
{
public function action(Category $category, Breadcrumbs $breadcrumbs)
{
$node = $category;
while ($node) {
$breadcrumbs->prependItem($node->getName(), '<category URL>');
$node = $node->getParent();
}
}
}
use Xepozz\BreadcrumbsBundle\Model\Breadcrumbs;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class Controller extends AbstractController
{
public function action(Breadcrumbs $breadcrumbs, UrlGeneratorInterface $urlGenerator)
{
// Pass "_demo" route name without any parameters
$breadcrumbs->addRouteItem('Demo', '_demo');
// Pass "_demo_hello" route name with route parameters
$breadcrumbs->addRouteItem('Hello Breadcrumbs', '_demo_hello', [
'name' => 'Breadcrumbs',
]);
// Add "homepage" route link at the start of the breadcrumbs
$breadcrumbs->prependRouteItem('Home', 'homepage');
}
}
use Xepozz\BreadcrumbsBundle\Model\Breadcrumbs;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
class Controller extends AbstractController
{
public function action(Breadcrumbs $breadcrumbs, UrlGeneratorInterface $urlGenerator)
{
// Simple example
$breadcrumbs->prependNamespaceItem('subsection', 'Home', $urlGenerator->generate('index'));
// Example without URL
$breadcrumbs->addNamespaceItem('subsection', 'Some text without link');
// Example with parameter injected into translation "user.profile"
$breadcrumbs->addNamespaceItem('subsection', $txt, $url, ['%user%' => $user->getName()]);
// Example with route name with