Whats a best practice to link a page inside a page template

Novice User asked on September 20, 2018 00:04

I want to create a link to a page inside a page template. How should I link it so if that page is moved the link should not be broken. Is there a macro that get the URL from the document name or something ?

What is the best practice to link pages ?

Correct Answer

David te Kloese answered on September 20, 2018 13:50

What we use quite often for "semi static" is to make them manageable from the CMS without a developer by using Custom settings. See documentation on how to create custom settings here: docs.kentico.com/.../Addingcustomwebsitesettings-Definingcustomsettings)

This way you can deploy your template and make the setting itself different for different sites/environments/or what ever rule you want.

You could use the following macro to get a site specific setting:

{% GetAbsoluteURL(CMSContext.Current.Settings.CMSAccessDeniedPageURL) |(identity)GlobalAdministrator%}

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on September 20, 2018 03:17 (last edited on December 10, 2019 02:31)

You can use Related Pages. Just define a relationship. There are related pages web parts or macro will work as well CurrentDocument.RelatedDocuments["relationshipname"].FirstItem.Transform("{# AbsoluteURL #}").

P.S. You can always directly insert a link to specific document if you want to. You can use macro something like {% Documents.Where("DocumentID = 123").FirstItem.AbsoluteURL |(identity)GlobalAdministrator%} get specific document.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.