Giter Club home page Giter Club logo

breadcrumbbundle's Introduction

/!\ Repository not maintained and outdated /!\

CnertaBreadcrumbBundle

The CnertaBreadcrumbBundle provide an easy way to create a breadcrumb with KnpMenuBundle for Symfony2.

If you want to take a look, this Symfony2 app is my Sandbox, DemoMenu.

SensioLabsInsight

Build Status Latest Stable Version Latest Unstable Version

Install the Bundle

  1. Add the sources in your composer.json
     "require": {
        // ...
        "cnerta/breadcrumb-bundle": "2.1.*"
    }
  1. Then add it to your AppKernel class::
    // in AppKernel::registerBundles()
    $bundles = array(
        // ...
        new Cnerta\BreadcrumbBundle\CnertaBreadcrumbBundle(),
        // ...
    );

Default configuration

You don't have to configure anything. This part is only usefull if you want to setup a default breadcrumb template.

config.yml

    cnerta_breadcrumb:
        twig:
            template: CnertaBreadcrumbBundle::cnerta_breadcrumb.html.twig

Rendering Breadcrumb

First create your menu with the KnpMenuBundle.

Next, in your twig template call :

    {{ cnerta_breadcrumb_render('MyWonderfullBundle:Builder:Menu') }}

Or if you just want to get the breadcrumb array and make your stuff :

    {% set currentItem = cnerta_breadcrumb_get('MyWonderfullBundle:Builder:Menu') %}
    {# some crazy stuff #}
    {% for item in currentItem %}
        {% if loop.index != 1 %}
            {% if loop.index > 1 %} > {% endif %}
            {% if not loop.last %}<a href="{{ item.uri }}">{{ item.label }}</a>
            {% else %}<span>{{ item.label }}</span>{% endif %}
        {% endif %}
    {% endfor %}

If you want to use your own template for rendering :

    {{ cnerta_breadcrumb_render('MyWonderfullBundle:Builder:Menu', {'template': 'MyWonderfullBundle:Breadcrumb:myBreadcrumb.html.twig'}) }}

Unit test the Bundle

Before running phpunit you must load dependencies. This will only load the required vendors needed for run test.

     composer install --dev

After that you can run phpunit.

      ./vendor/bin/phpunit -c phpunit.xml.dist

Changelog

Version 2.1.0 (2015/10/19)

  • #4 Remove an unnecessary function who remove a node labeled "root"

breadcrumbbundle's People

Contributors

waldo2188 avatar wtfred avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.