0

I'm using SiteCore 7 MVC and Glassmapper.

I have a set of samples which are rendered using razor and set as standard values when an Author/Editor creates a new page. I wish to prevent the editor from modifying these samples in the PageEditor.

I have used

Model.FullPath.Contains("sample") 

to check if the item being rendered is an item from the sample folder.

This technique works with images using:

@RenderImage(x => x.Image, isEditable:!Model.FullPath.Contains("sample"))

However when I render rich edited text fields (generated by TinyMce) in the following manner:

@(Model.FullPath.Contains("sample") ? 
       Html.Raw(Model.RichTextLeft) : 
       Editable(x => x.RichTextLeft))

The field remains editable even when rendered separately. I have tried using

@Html.Sitecore().Field("SectionTitle")

to render the field (which actually renders nothing).

and

@Html.Raw(Model.RichTextLeft)

to no avail

Any advice would be appreciated.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Ovee
  • 1
  • 3
  • Looks to me like your Model.FullPath.Contains("sample") is never true in your case and it therefore always renders Editable(x => x.RichTextLeft)... There is no way that Html.Raw(Model.RichTextLeft) outputs an editable field (unless it returns a FieldEditor control, but that seems unlikely) – Ruud van Falier Mar 19 '14 at 13:16
  • Hi @Ruud, Thanks for your answer. Having continued with this it appeared that the Model that was being passed already contained the editor mark up and that Html was was simply rendering that. As a workaround I utilised `code @(Model.FullPath.ToLower().Contains("samples") ? Html.Raw(Sitecore.Context.Database.GetItem(new Sitecore.Data.ID(Model.Id))["RichTextLeft"]): Editable(x => x.RichTextLeft)) ` as a method of pulling the value with no mark up added by the mapper. – Ovee Mar 19 '14 at 14:45
  • I think this is a bug, please log on github – Michael Edwards Mar 20 '14 at 07:32
  • I have logged the issue. – Ovee Mar 20 '14 at 14:50

1 Answers1

0

This issue has been fixed and is available in from the Glass.Mapper build server, this will be in the main release soon.

Michael Edwards
  • 6,308
  • 6
  • 44
  • 75