2017 © Pedro Peláez
 

symfony-bundle bcm-breadcrumbbundle

Provides tools to create breadcrumb

image

benoitmariaux/bcm-breadcrumbbundle

Provides tools to create breadcrumb

  • Thursday, March 20, 2014
  • by benoitMariaux
  • Repository
  • 1 Watchers
  • 2 Stars
  • 62 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

BCMBreadcrumbBundle

BCMBreadcrumbBundle allows you to generate breadcrumbs easily for your Symfony project., (*1)

Installation

With composer, add:, (*2)

{
    require: {
        "benoitmariaux/bcm-breadcrumbbundle": "dev-master"
    }
}

Then enable it in your kernel:, (*3)

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        ...
        new BCM\BreadcrumbBundle\BCMBreadcrumbBundle(),
        ...

Usage

First step : the routes

You have to configure two attributes (label and parent) to defaults in routes you want to add to your breadcrumb :, (*4)

homepage:
    pattern: /
    defaults:
        _controller: AcmeDemoBundle:Default:home
        label: homepage # no parent for homepage

articles:
    pattern: /articles
    defaults:
        _controller: AcmeDemoBundle:Article:list
        label: ARTICLES
        parent: homepage

article:
    pattern: /articles/show/{article_id}
    defaults:
        _controller: AcmeDemoBundle:Article:article
        label: '{article_title}'
        parent: articles

Second step : the controller

Inject all parameters you need for current breadcrumb routes and labels, (*5)

$breadcrumb = $this->get('bcm_breadcrumb.manager')->render(array(
    'article_title' => $article->getTitle(), // useful for article route label
    'article_id' => $article->getId() // useful for article route pattern
));

return $this->render('AcmeDemoBundle:Default:article.html.twig', array(
    'article' => $article,
    'breadcrumb' => $breadcrumb
));

Last step : the view

{{ breadcrumb|raw }}

Your own view

The default view is: vendor/benoitmariaux/bcm-breadcrumbbundle/BCM/BreadcrumbBundle/Resources/views/bcm-breadcrumb.html.twig, (*6)

You can overwrite it by creating your own here: app/Resources/BCMBreadcrumbBundle/views/bcm-breadcrumb.html.twig, (*7)

Label translation

You can define translations for your labels with the default domain breadcrumb: * breadcrumb.fr.xliff * breadcrumb.de.xliff, (*8)

The Versions

20/03 2014

dev-master

9999999-dev https://github.com/benoitMariaux/BCMBreadcrumbBundle

Provides tools to create breadcrumb

  Sources   Download

MIT

The Requires

 

by Benoît Mariaux

breadcrumb navigation