symfonytwig

redirect to page#about using symfony&twig


I'm using Symfony , I wanna redirect the user to a specific frame in a page So How can i translate this <a href="index.html#about"/> to twig ? I tried <a href="{{path('pl_index')}}#about"/> but it doesnt work


Solution

  • in twig you can use {{path('_welcome') }} and it will send you to your home index, check your route.yml and you can see what are the paths generated by symfony.

    for example this is my config.yml:

    //savabundle config.yml
        sava_inventario_construccion:
            path:     /productos/construccion
            defaults: { _controller: savaInventarioBundle:Inventario:construccion }
        sava_inventario_index:
            path:     /productos/
            defaults: { _controller: savaInventarioBundle:Inventario:index }
    

    if i want to generate www.mypage.com/productos/construccion#about link, this is what my html should look like

    <a href="{{path('sava_inventario_construccion') }}#about"/>
    

    you can read more in here http://symfony.com/doc/current/book/templating.html