I am using Sulu as CMS and added some pages. Additionally I have some custom Symfony actions with their own twig templates.
Now I want to add a link into the twig template that directs the user to one of the CMS pages. How can I achieve that?
I know about sulu-link
but what should I put into its href
attribute?
Well, it is easier than I thought. The doc states
The sulu-link tag allows to link to pages and other entities in the application by their id. This id of the tag will be validated and replaced by a proper anchor tag when a response is generated.
The id corresponds to the UUID of the page and you can find it in the URL, if you open the page in the admin area.
Example:
Open your page in the administration. Let's say its URL is https://example.com/admin/#/webspaces/platform/pages/de/f80713e3-1e91-43b8-8351-1f3124b12878/details
To create a link in your twig template, add this snippet:
<sulu-link href="f80713e3-1e91-43b8-8351-1f3124b12878">label of my link</sulu-link>