Thursday 15 July 2010

symfony - Get controller name in TWIG template -


I am learning symfony2.3, and when I try to get the name of the controller in the toggle template, Get the error.

Controller:

  Namespace Acme \ AdminBundle \ Controller; Use Symfony \ Bundle \ FrameworkBundle \ Controller \ Controller; Use Symfony \ Component \ HttpFoundation \ Request; Class Default Controller Controller {Public Function Index Action ($ name) {Return $ this- & gt; Reader ('Acme Admin Bundle: Default: index.html.twig', array ('name' = & gt; $ name)); }}   

In my TWIG template:

  {% extends ':: base.html.twig'%} {% block entity%} {{ App.request.get ('_ template'). Get ('Admin')}} Hello {{name}} !!! {% Endblock%}   

Output:

  To implement a method ("Received") on a null variable ("") in AcmeAdminBundle Impossible: Default: Index.html.twig on line 3   

I want output as "default"

I am using Symphon 2.3, I have a symphony 2.1, but the version on both of them generates the same error.

Use this line to display the controller name in the trigger:

  {{app.request.attributes.get ("_controler")}}    

No comments:

Post a Comment