sfBreadcrumbs plugin
Updates
- Added Support to I18N, just translate the module's, section's, and action's DisplayNames? and you're good to go.
- Now you can use the plugin without defining the module sections, although I don't see the point of using the plugin without defining the breadcrumbs path.
Overview
This plugin adds the ability to create Breadcrumbs(AKA: Navigation Path) in any template. The plugin works with symfony 1.0.x, and wasn't tested in symfony 1.1
Installation
To install sfHelperExample:
symfony plugin-install http://plugins.symfony-project.com/sfBreadcrumbsPlugin
Adding support to Breadcrumbs
breadcrumbs.yml
Create a file named breadcrumbs.yml (with the structutre described below) in any of the config folders located in your apps(ex: apps/myapp/config)
config.php
In the same app directory were you've placed the breadbrumbs.yml, add the following to the config.php file:
include_once( sfConfigCache::getInstance()->checkConfig( sfConfig::get('sf_app_config_dir_name').'/breadcrumbs.yml' ) );
config_handlers.yml
In the same app directory were you've placed the breadcrumbs.yml, add the following to the config_handlers.yml(create it if necessary):
breadcrumbs.yml: class: sfBreadcrumbsConfigHandler
Clear the cache
symfony cc
Forum Topic
http://www.symfony-project.org/forum/index.php/t/13034/
Usage
All you have to do is to open the breadcrumbs.yml file located in folder config in the sfBreadcrumbsPlugin folder and follow the next examples. Suppose you're working on a website where the main navigation menu consists of the following items:
- Home
- Categories
- Show All
- Add New
- Products
- Show All
- Add New
And as you might have guessed, Home, Categories, and Products are just virtual sections in the website grouping some actions together, for example, the Show All and Add New actions for categories or products. Since all these actions are probably placed in the same module it's hard to display the Breadcrumbs to the user based on just the action and module names, and this is where this plugin comes in handy. Consider the following breadcrumbs.yml example, and don't be intimidated, I'll explain each node in the file.
In the below example, mymodule is a name of a module available in an application for example called myapp. mymodule consists of several actions:
- categoriesAction
- showCategoriesAction
- addNewCategoryAction
- productsAction
- showProductsAction
- addNewProductAction
As you can see, some of these actions are related to a certain entity(ex: Category), and I want to group categoriesAction, showCategories, and addNewCategory in a menu(i.e. section) called Categories. All I've to do is write the following in breadcrumbs.yml under tags.
all:
mymodule:
name: My Module
sections:
categories:
name: Categories
actions:
categories:
name: Categories
newCategory:
name: New Category
showCategories:
name: Show Available Categories
products:
name: Products
actions:
products:
name: Product
newProduct:
name: New Product
showProducts:
name: Show Available Products
In the above example, mymodule is the actual name of the module, My Module, is the name displayed in the Breadcrumbs presented to the user. The same goes for section, and action.
Now in order to display the breadcrumbs text in the website, open for example the layout.php located in the templates folder under your application, and add the following anywhhere, enjoy.
<?php echo sfBreadcrumbs::getInstance()->getBreadcrumbText() ?>
To-Do
- Add parameters to the Breadcrumbs text
- Write complete API and User documentation
License
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Attachments
- sfBreadcrumbsPlugin-1.0.0.tgz (6.5 kB) - added by Ahmed.El.Hussaini on 05/20/08 14:27:13.
- sfBreadcrumbsPlugin-1.0.1.tgz (5.6 kB) - added by Ahmed.El.Hussaini on 05/29/08 10:47:23.
- sfBreadcrumbsPlugin-1.0.2.tgz (5.7 kB) - added by Ahmed.El.Hussaini on 06/01/08 10:53:23.
- sfBreadcrumbsPlugin-1.0.3.tgz (5.7 kB) - added by Ahmed.El.Hussaini on 06/07/08 00:04:51.