0
votes

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.

1
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
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
I think this is a bug, please log on githubMichael Edwards
I have logged the issue.Ovee

1 Answers

0
votes

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