I am following online tutorial for Symfony CMS: http://symfony.com/doc/master/cmf/tutorial/introduction.ht ml
I am getting the error:
An exception has been thrown during the rendering of a template ("The menu "main" is not defined.") in src\Acme\BasicC msBundle\Resour ces\views\Defau lt\page.html.tw ig at line 4.
500 Internal Server Error - Twig_Error_Runt ime
1 linked Exception:
InvalidArgument Exception ยป
I am on the page about menu
http://symfony.com/doc/master/cmf/tutorial/the-frontend.html
Where is the mistake?
I am getting the error:
An exception has been thrown during the rendering of a template ("The menu "main" is not defined.") in src\Acme\BasicC msBundle\Resour ces\views\Defau lt\page.html.tw ig at line 4.
500 Internal Server Error - Twig_Error_Runt ime
1 linked Exception:
InvalidArgument Exception ยป
I am on the page about menu
http://symfony.com/doc/master/cmf/tutorial/the-frontend.html
Where is the mistake?
Code:
<?php
// src/Acme/BasicCmsBundle/DataFixtures/PHPCR/LoadPageData.php
namespace Acme\BasicCmsBundle\DataFixtures\PHPCR;
use Acme\BasicCmsBundle\Document\Page;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\PHPCR\DocumentManager;
class LoadPageData implements FixtureInterface
{
public function load(ObjectManager $dm)
{
if (!$dm instanceof DocumentManager) {
$class = get_class($dm);
throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
}
$parent = $dm->find(null, '/cms/pages');
$rootPage = new Page();
$rootPage->setTitle('main');
$rootPage->setParentDocument($parent);
$dm->persist($rootPage);
$page = new Page();
$page->setTitle('Home');
//$page->setParentDocument($parent);
$page->setParentDocument($rootPage);
$page->setContent(<<<HERE
Welcome to the homepage of this really basic CMS.
HERE
);
$dm->persist($page);
$page = new Page();
$page->setTitle('About');
$page->setParentDocument($rootPage);
$page->setContent(<<<HERE
This page explains what its all about.
HERE
);
$dm->persist($page);
$dm->flush();
}
}
Code:
{# src/Acme/BasicCmsBundle/Resources/views/Default/page.html.twig #}
<h1>{{ page.title }}</h1>
{{ knp_menu_render('main') }}
<p>{{ page.content|raw }}</p>
<h2>Our Blog Posts</h2>
<ul>
{% for post in posts %}
<li><a href="{{ path(post) }}">{{ post.title }}</a></li>
{% endfor %}
</ul>