This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text.RegularExpressions; | |
using Sitecore.Mvc.Presentation; | |
using Sitecore.Mvc.Pipelines.Response.GetRenderer; | |
namespace Paragon.Sc.Mvc.Pipelines | |
{ | |
public class GetViewRenderer : Sitecore.Mvc.Pipelines.Response.GetRenderer.GetViewRenderer | |
{ | |
public override void Process(GetRendererArgs args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<pipelines> | |
<mvc.getrenderer> | |
<processor | |
patch:instead="processor[@type='type=Sitecore.Mvc.Pipelines.Response.GetRenderer.GetViewRenderer, Sitecore.Mvc']" | |
type="Paragon.Website.Sc.Mvc.Pipelines.GetViewRenderer, Paragon.Website.Sc.Mvc" /> | |
</mvc.getrenderer> | |
</pipelines> | |
</sitecore> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
<sitecore> | |
<pipelines> | |
<renderContentEditor> | |
<processor | |
patch:instead="processor[@type='Sitecore.Shell.Applications.ContentEditor.Pipelines.RenderContentEditor.RenderStandardContentEditor, Sitecore.Client']" | |
type="Paragon.Sc.ContentEditor.Pipelines.RenderContentEditor.RenderCustomizedContentEditor, Paragon.Sc.ContentEditor" /> | |
</renderContentEditor> | |
</pipelines> | |
</sitecore> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RenderCustomizedContentEditor | |
{ | |
public void Process(RenderContentEditorArgs args) | |
{ | |
var editorFormatter = new EditorFormatter(args); | |
editorFormatter.RenderSections(args.Parent, args.Sections, args.ReadOnly); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class ContentEditorRuleContext : RuleContext, ISerializable | |
{ | |
public List<IMappedItem> MappedItems { get; set; } = new List<IMappedItem>(); | |
public void GetObjectData(SerializationInfo info, StreamingContext context) | |
{ | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum MappedItemType { Section, Field } | |
public class MappedItem | |
{ | |
public MappedItemType Type { get; set; } | |
public string OriginalName { get; set; } | |
public string NewTitle { get; set; } | |
public string ShortDescription { get; set; } | |
public bool Hide { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HideFields<T> : RuleAction<T> where T : ContentEditorRuleContext | |
{ | |
public string FieldName { get; set; } | |
public override void Apply(T ruleContext) | |
{ | |
var mappedItem = | |
MappedItemExtensions.GetItem(ruleContext.MappedItems, MappedItemType.Field, FieldName) ?? | |
new MappedItem(); | |
mappedItem.Type = MappedItemType.Field; | |
mappedItem.OriginalName = FieldName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EditorFormatter | |
{ | |
public RenderContentEditorArgs Arguments { get; set; } | |
public List<IMappedItem> MappedItems { get; set; } = new List<IMappedItem>(); | |
public EditorFormatter(RenderContentEditorArgs args) | |
{ | |
Arguments = args; | |
// We want to make sure the Item is under the Content Node and that the item is not null. | |
if (args.Item == null || !args.Item.Paths.IsContentItem)return; | |
// Run the rules and set it to MappedItems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MappedItemExtensions | |
{ | |
public static IMappedItem GetMappedItem(IEnumerable<IMappedItem> mappedItems, MappedItemType itemType, string originalName) | |
{ | |
return mappedItems.FirstOrDefault(x => x.OriginalName.EndsWith(originalName) && x.Type.Equals(itemType)); | |
} | |
public static IEnumerable<T> AddOrReplaceItem<T>(this List<T> list, T item) where T : IMappedItem | |
{ | |
var idx = list.FindIndex(x => x.OriginalName.Equals(item.OriginalName)); | |
if (idx.Equals(-1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Html.Glass().Editable(model, x => x.Summary, x => $"<p>{x.Summary}</p>")) |
OlderNewer