index has the simplest configuration. It tells the plugin to show just one breadcrumb with name "Blog" and
linked to the route "blog", which is a sfRoute object.
blog:
index:
- { name: 'Blog', route: blog }
showPost is a little more complex. It consists of two breadcrumbs; the first is identical to the index one,
but the second tells the plugin to show a breadcrumb for a sfDoctrineRoute object. You can set this by
adding the doctrine parameter to the breadcrumb element. More, you can set the name of the breadcrumb by
taking a property from the model object the route is bound to.
Example: if I have this routing rule...
post_show:
url: /blog/post/:date_slug/:slug.:sf_format
class: sfDoctrineRoute
options: { model: Post, type: object }
param: { module: blog, action: showPost, sf_format: html }
requirements:
slug: '[\w-]+'
sf_method: [get]
...and I can write this...
$post = new Post();
$post->setTitle('My title');
echo $post->getTitle(); // 'My title'
...than I can set as name of my breadcrumb the "title" property of my Post object, by putting it within
percent signs:
- { name: %title%, route: post_show, doctrine: true }
What if you are in a sfDoctrineRoute rule action and you want to point your breadcrumb to a rule for another
model object? Let's take a look at the second permalink breadcrumb:
- { name: %Post%, route: post_show, doctrine: true, subobject: Post }
Now, my current routing rule is this one:
post_permalink:
url: /archive/:year/:month/:day/:slug.:sf_format
class: sfDoctrineRoute
options: { model: Permalink, type: object }
param: { module: blog, action: permalink, sf_format: html }
requirements:
sf_method: [get]
My route object is a Permalink object, but if I can write this...
$permalink = new Permalink();
$permalink->getPost(); //fetch original post
...then I can tell the plugin to create a breadcrumb that takes a subobject (a Post) via class method
from my rule object (the Permalink) and link it to a sfDoctrineRoute suitable for the subobject.