1

I have 2 data template fields "title" and "id", used for the HTML page title and the id attribute in the body tag respectively. When the page is viewed using Page Editor, Sitecore attempts to render editor controls on these items and because they are outside of the main form tag, controls don't get rendered correctly. I don't need these to be editable in the Page Editor.

  1. What's the best approach/solution to handle fields like these?
  2. Is hiding these 2 template fields from the Page Editor a solution?
  3. If so, how do you hide the fields from the Page Editor and still have it available on the Content editor (so we can still edit it within the Content editor)?
Martin Davies
  • 4,436
  • 3
  • 19
  • 40
Ronnie Liew
  • 18,220
  • 14
  • 46
  • 50

1 Answers1

4

In Page Editor, all you should need to do is render their values without a FieldRenderer. e.g, bind the field values to a standard .NET control. Or use a scriptlet -- <%=Sitecore.Context.Item["Title"]%>

nickwesselman
  • 6,845
  • 2
  • 27
  • 46
  • Thanks for pointing me to the right direction. I ended up using this: `<%=Sitecore.Context.Item.Fields["Page Title"]%>` – Ronnie Liew Mar 13 '12 at 08:01
  • 1
    No problem. Be careful w/ the .Fields collection. As you have it here, probably couldn't cause a NullRef, but if you use the dictionary directly on the item (i.e. Item["Title"]) the worst that you'll get is an empty string. – nickwesselman Mar 13 '12 at 12:56