I have a HomeBundle in which I have Default controller that has 2 actions : one to render index.html.twig and another one to render part of the navbar. In my views, I have the default layout that the rest of the views extends.
I want to match the route of the second action in the Default controller to render its content to any route.
This is the action in DefaultController, I thought name="/"
would match all routes.
/**
* @Route("/", name="navbar_boutique")
*/
public function afficherBoutiqueProductAction()
{
$em= $this->getDoctrine()->getManager();
$boutiques=$em->getRepository(Boutique::class)->findAll();
return $this->render('@Souk/Default/boutique_navbar.html.twig', array(
"boutiques"=>$boutiques
));
}
And this is boutique_navbar.html.twig:
{%extends '@Souk/layout.html.twig'%}
{%block boutique %}
<ul class="list-links">
<li>
<h3 class="list-links-title">Liste des Boutiques</h3></li>
{% for b in boutiques %}
<li><a href="{{ path('afficher_produit_boutique',{'idboutique':b.id}) }}"> {{ b.nom }} </a></li>
{% endfor %}
</ul>
{% endblock boutique %}
As for layout.html.twig it contains the base template and I just want to display an element in its navbar. (it's the list of shops)
What am I doing wrong?
ps: When I add @Route="/test"
for example, it works but only for /test and I want it to be for all routes.