-
Create URL from page ID
Hi community,
I'm new here, unfortunately can only write on English.
I was not able to get/create URL to page using page ID.
I've created a pageTree field in DCA, and now in custom template have just ID in variable. But I want to create link to that page. Is there any hint or code snippet on how to create link.
Thank you in advance.
-
That's easy:
PHP-Code:
$url = \Contao\PageModel::findById($id)->getFrontendUrl(); // use ->getAbsoluteUrl(); for an URL including scheme and host
-
Thank you!
For now I used just text field and c/p the whole page (external )URL