This file contains hidden or 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
| protected override void OnInit(EventArgs e) | |
| { | |
| btn.Click += new EventHandler(btn_Click); | |
| var form = this.SitecoreContext.GetCurrentItem<Templates.EditableExample>(); | |
| base.OnInit(e); | |
| ddlExample.DataSource = form.TreeList; | |
| ddlExample.DataTextField = "Name"; |
This file contains hidden or 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
| // First create an attribute that specifies that the property should load the rendering refences | |
| public class SitecoreRenderingsAttribute : AbstractSitecorePropertyAttribute | |
| { | |
| public Device Device { get; set; } | |
| } | |
| //I am using an enumeration to determine which device to load | |
| public enum Device | |
| { |
This file contains hidden or 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 SitecoreRenderingsHandler : AbstractSitecoreDataHandler | |
| { | |
| public override bool WillHandle(SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) | |
| { | |
| //it was this: | |
| //return property.Attribute is SitecoreRenderingsAttribute && property.Property == typeof(IEnumerable<RenderingReference>); | |
| //should be this | |
| return property.Attribute is SitecoreRenderingsAttribute && property.Property.PropertyType == typeof(IEnumerable<RenderingReference>); |
This file contains hidden or 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 void ApplicationStart(){ | |
| var context = Context.Create(new GlassConfig()); | |
| } |
This file contains hidden or 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
| context.Load(new SitecoreAttributeConfigurationLoader("Your.Assembly.Name")); |
This file contains hidden or 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 CommentController : SitecoreController | |
| { | |
| ISitecoreContext _context; | |
| ISitecoreService _master; | |
| /// <summary> | |
| /// This constructor can be used with dependency injection or unit testing | |
| /// </summary> | |
| /// <param name="context"></param> | |
| public CommentController(ISitecoreContext context, ISitecoreService master) |
This file contains hidden or 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
| @inherits System.Web.Mvc.WebViewPage<UserGroup.Models.CommentPage> | |
| @using System.Web.Mvc.Html | |
| @using Sitecore.Mvc | |
| @using Sitecore.Mvc.Contrib.Html; | |
| @Html.Sitecore().Placeholder("webedit") | |
| <div> | |
| <h3>Comments</h3> | |
| @if (Model.CommentAdded) | |
| { |
This file contains hidden or 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
| var master = new SitecoreService("master"); | |
| var context = master.InstanceContext; |
This file contains hidden or 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
| var currentItem = context.GetCurrentItem<Parent>(); | |
| var newChild = new Child(); | |
| //we use the Name property as the item name when creating an item | |
| newChild.Name = "MyNewChild"; | |
| //you can map other properties here | |
| newChild.PageTitle ="My New Child"; |
This file contains hidden or 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
| Another solution would be to use the Sitecore profiler. | |
| In the PerformanceMonitor.Start add Sitecore.Diagnostics.Profiler.StartOperation(key); | |
| And in the end: | |
| Sitecore.Diagnostics.Profiler.EndOperation(key); | |
| You will then see the processing time outputted into the Sitecore Debug tool. |