If I want to create a link to a page in a Sulu twig template, I can use the <sulu-link />
tag, which is fine for most usecases. But sometimes I do not want an anchor tag rendered, but only the URL, for example to pass it to a javascript function or to use it in a form action.
In Sulu v2.5 this worked:
{% set termsAgreement = sulu_content_load('123-123-123-123') %}
{% set termsAgreementUrl = sulu_content_path(termsAgreement.urls[request.defaultLocale]) %}
Unfortunately this does not work in Sulu v2.6, as the urls
property is not returned anymore by sulu_content_load
. According to the sulu docs the urls
property is deprecated.
Of course, something like this would work
{% set termsAgreementUrl = sulu_content_path('/terms-agreement') %}
assuming the resourcelocator for the desired page is "terms-agreement". But when the resourelocator is changed in the admin interface, the url is broken.
So long story short: How can I get the URL to a Sulu page in twig by using its content id?