Reputation: 1751
I have in Twig an link:
link
Which outputs as url: www.domain.com/category-laptops
But on dev I need to output: www.domain.com/app_dev.php/category-laptops
Is there some function for this, or should I write by my own based on the environment?
Thanks Nik
Upvotes: 0
Views: 433
Reputation: 332
If you've set up the route correctly then path('route_name')
should give you the correct link in both environments.
Upvotes: 1
Reputation: 2549
You have to use {{ path() }}
in your twig-template for that.
example:
<a href="{{ path('article_show', {'slug': article.slug}) }}">
{{ article.title }}
</a>
See: http://symfony.com/doc/current/reference/twig_reference.html#path
If you want to use absolute links, you can use {{ url() }}
instead of {{ path() }}
See: http://symfony.com/doc/current/reference/twig_reference.html#url
Upvotes: 3