Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 2fc55bb

Browse files
committed
Merge pull request #474 from symfony-cmf/cookbook-cms-tutorial
mention templates_by_class in tutorial
2 parents cc3fa0f + 951cab6 commit 2fc55bb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cookbook/creating_a_cms/content-to-controllers.rst

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ object and all the ``Posts`` to the view::
7171
*/
7272
public function pageAction($contentDocument)
7373
{
74-
$dm = $this->get('doctrine_phpcr')->getManager();
75-
$posts = $dm->getRepository('Acme\BasicCmsBundle\Document\Post')->findAll();
74+
$dm = $this->get('doctrine_phpcr')->getManagerForClass('AcmeBasicCmsBundle:Post');
75+
$posts = $dm->getRepository('AcmeBasicCmsBundle:Post')->findAll();
7676

7777
return array(
7878
'page' => $contentDocument,
@@ -125,3 +125,12 @@ router and because it implements the ``RouteReferrersReadInterface`` the
125125

126126
Click on a ``Post`` and you will have the same error that you had before when
127127
viewing the page at ``/home`` and you can resolve it in the same way.
128+
129+
.. tip::
130+
131+
If you have different content classes with different templates, but you
132+
don't need specific controller logic, you can configure
133+
``templates_by_class`` instead of ``controllers_by_class`` to let the
134+
default controller render a specific template. See
135+
:ref:`bundles-routing-dynamic_router-enhancer` for more information on
136+
this.

0 commit comments

Comments
 (0)