Note that there are some explanatory texts on larger screens.

plurals
  1. POSymfony 2.3.3 Embedding Controller
    text
    copied!<p>Im trying to embed a controller inside a twig template. Its documented here: <a href="http://symfony.com/doc/current/quick_tour/the_view.html" rel="nofollow noreferrer">http://symfony.com/doc/current/quick_tour/the_view.html</a> and have read various questions on stackoverflow about it like this one: <a href="https://stackoverflow.com/questions/15221230/how-to-insert-a-controller-in-twig-with-render-in-symfony-2-2">How to insert a Controller in Twig with &quot;render&quot; in Symfony 2.2?</a></p> <p>However, when I try to embed my controller i get an error: "<strong>The function 'controller' does not exist</strong>"</p> <p>My twig template looks like this:</p> <pre><code>&lt;div class="section"&gt; &lt;div id="a" class="section_column"&gt; {{ render(controller('MySymfonyBundle:AccessPage:load', {'page_id':'1'})) }} &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The controller that is being embedded does some db selects etc then renders another view to include inside this template.</p> <p>This is the full error:</p> <pre><code>array( ['message'] =&gt; 'Uncaught PHP Exception Twig_Error_Syntax: "The function "controller" does not exist in "&lt;div id="{{ identifier }}" class="section"&gt; &lt;div id="a" class="section_column"&gt; {{ render(controller('ABCBundle:Site:grabPage', {'page_id':'1'})) }} &lt;/div&gt; &lt;/div&gt;" at line 3" at /www/vendor/twig/twig/lib/Twig/ExpressionParser.php line 555' ['context'] =&gt; array( ['exception'] =&gt; array( ) ) ) </code></pre> <p>this just doesnt seem to work =( Where am I going wrong?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload