I have a blog and have two routes which redirect to my profile page and my "update profile" page
@Route("/profil/{slug}", name="profile")
@Route("/profil/{slug}/infos", name="profile_update")
And those routes have two links in my navbar which is a part of my base.html.twig template
So in my base.html.twig I did something like this
<a href="{{ path('profile', {'slug' : membre.slug }) }}" class="dropdown-item">Account</a>
<a href="{{ path('profile_update', {'slug' : membre.slug }) }}" class="dropdown-item">Update profile</a>
But it says "variable membre does not exist" :(
It only works in my profile route because in its template I also have those link inside the page so in the controller I did :
/**
* @Route("/profil/{slug}", name="profile")
*/
public function profile(Membre $membre){
return $this->render('blog/profile.html.twig', [
'membre' => $membre
]);
}
and it works, but base.html.twig has NO CONTROLLER it's just a "base" template so how am I suppose to tell it where the variable is from?
Thank you
Membreis the logged-in user, you can useapp.userin your template.