Page type property values in page template layout macro

Gerard Young asked on July 9, 2019 11:21

Is is possible to access the value of a page type property using macros in the layout of a page template?

eg. I have a TeaserText field on the page type. I would like to display this on a Portal page template in the ASCX template using a macro.

I have hunted through documentation and the macro helper to no avail.

Correct Answer

Dmitry Bastron answered on July 9, 2019 12:49

Hi Gerard,

K# Macro syntax {% %} is not working in ASCX templates. It's working only within Text/HTML. But you can access the field of current page with the following C# script in the ASCX Page Template:

<%= CurrentDocument.GetValue("YourCustomField") %>
<%= CurrentDocument.DocumentName %>

Also, you can use any other C# code as well =)

2 votesVote for this answer Unmark Correct answer

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