Page Menu Item custom field in template

Guido Paolano asked on December 7, 2017 18:45

I would like to put a CSS class as a field on the menu item page type so that I don't have to make a new template for minor changes. I created a copy of the Page menu item type and added a "CSSClass" field to it. Then, on the template I have this: <div class= "<%# Eval("CSSClass") %>" > But it is empty.

Is this possible?

Thank you.

Correct Answer

Guido Paolano answered on December 12, 2017 19:55

Thank you for the answers. The Macro Resolver still wasn't showing up for me, but the Document Context worked.

Thank you both!

0 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on December 7, 2017 19:02 (last edited on December 10, 2019 02:31)

You need to use macro: <div class= "{%CurrentDocument.GetValue("CSSClass")|(identity)GlobalAdministrator%}" >

1 votesVote for this answer Mark as a Correct answer

Guido Paolano answered on December 7, 2017 19:08

Is it possible using an ASCX layout type?

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on December 7, 2017 19:55 (last edited on December 10, 2019 02:31)

Are you trying to resolve macro in the ASCX transformation? <%= CMS.MacroEngine.MacroContext.CurrentResolver.ResolveMacros("{%CurrentDocument.CSSClass|(identity)GlobalAdministrator%}")%>

1 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on December 7, 2017 21:44

Should also be able to do:

<%= CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue<string>("CSSClass", "DefaultValue") %>

May or may need the CMS.DocumentEngine portion of the above, since it may be already there, or you can use a <%@ Import Namespace="CMS.DocumentEngine" %> on top of the transformation

0 votesVote for this answer Mark as a Correct answer

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