I was successful with getting Symfony CMF and Auto Routing Bundle (and a custom contoller) to load documents in the following manner (path):
.../category/article-name
This works fine. But I need something like this, easily achieved by standard Symfony2:
.../category/article-name/{page}
Where page is passed to a controller as a parameter, eg. $page = 2 -> controller processes content of the Article document to display only given page or $page = null -> (so no {page} parameter at all) - as above, but displayed is page default that is 1
How to make routing-auto bundle of the Symfony CMF to use parameters in routes?
So that the basic path is exactly as it is configured as in this Auto Routing Bundle configuration, but additionally I can use parameters passed to a controller, so that additional decisions can be made upon them. Any hints? Thanks!
My config for auto routing:
MyApp\MyCmsBundle\Document\Article:
content_path:
#fixed path of all categories and therefore articles
articles_categories_path:
provider: [specified, { path: /cms/routes }]
exists_action: use
not_exists_action: throw_exception
#category path
category_path:
provider: [content_method, { method: getRouteNodeCategory }]
exists_action: use
not_exists_action: throw_exception
#article name
content_name:
provider: [content_method, { method: getTitle }]
exists_action: [auto_increment, { pattern: -%d }]
not_exists_action: create
MyApp\MyCmsBundle\Document\ArticlesCategory:
content_path:
#fixed path of all categories and therefore articles
articles_categories_path:
provider: [specified, { path: /cms/routes }]
exists_action: use
not_exists_action: throw_exception
#category name
content_name:
provider: [content_method, { method: getTitle }]
exists_action: use
not_exists_action: create
getRouteNodeCategory() of the Article Document just returns a parents (i.e. category) name. Here's part of this document content:
public function getRouteNodeCategory()
{
return $this->parent->getTitle();
}