prestaBreadcrumbPlugin - 0.0.1

Give an easy way to construct breadcrumbs

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

prestaBreadcrumbPlugin plugin

The prestaBreadcrumbPlugin plugin helps you to build breadcrumbs in your application.

Installation

  • Install the plugin:

    $ symfony plugin:install prestaBreadcrumbPlugin
    $ symfony cc
  • Enable the module and the helper prestaBreadcrumb in your applications config/app.yml:

    all:
      .settings:
         # Helpers included in all templates by default
        standard_helpers: [Partial, Cache, Form, prestaBreadcrumb]
        # Activated modules from plugins or from the symfony core
        enabled_modules: [default, prestaBreadcrumb]

Configuration

In your applications config/app.yml you can redefined default values. Parameters available :

  • home: The label for the homepage (default: 'Home')
  • home_uri: The uri for the homepage (default: '@homepage')
  • separator: Value printed between each link (default: ' > ')
  • template: Format string passed to sprintf in the render process (default: '%s')

Usage

Define crumbs in your actions:

public function executeMyAction()
{
    prestaBreadcrumb::getInstance()->addItem('Article', '@article');
}

Or, you can defined crumbs in your module config/breadcrumb.yml

article:
  text: 'Article'
  uri:  '@article'

If the crumbs are defined both in your actions and config/breadcrumb.yml, the configuration in your action will be used primarily.

Rendering the Breadcrumb

To output the breadcrumb, simply include the component.

include_component('prestaBreadcrumb', 'show');

You can also used the helper, like that.

$breadcrumbs = array(
    array('text' => 'News', 'uri' => '@news'),
    array('text' => 'Article', 'uri' => '@article'),
    // ...
);
display_prestabreadcrumb($breadcrumbs);

Or

$breadcrumb = prestaBreadcrumb::getInstance()
    ->addItem('News', '@news')
    ->addItem('Article', '@article')
;
display_prestabreadcrumb($breadcrumb);

Or, you can just call the render method.

prestaBreadcrumb::getInstance()->render();