i try call controller function in twig file with render but it give error this is my controller code this is controller path
\\src\\AppBundle\\Controller\\front\\MenusController.php
MenusController.php Code
<?php
namespace AppBundle\Controller\front;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class MenusController extends Controller
{
public function menuAllAction()
{
return $this->render('front/menus.html.twig');
}
}
and this code is my twig file code master.html.twig
{% render(controller('AppBundle:front:Menus:menuAll')) %}
but is return error please help me
Try like to replace {% %}
by {{ }}
:
{{ render(controller('AppBundle:front:Menus:menuAll')) }}
Edit:
{{ render(controller('AppBundle:Menus:menuAll')) }}
(the right synthax is: bundle:controller:action
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.