Created
January 23, 2017 19:39
-
-
Save cssquirrel/7670a845a9f1b20f74a3bf3abec3137f to your computer and use it in GitHub Desktop.
Example of creating a custom section in Umbraco
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; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Net; | |
using System.Xml; | |
using Umbraco.Core; | |
using Umbraco.Core.Models; | |
using Umbraco.Core.Persistence; | |
using Umbraco.Web; | |
namespace ExamplePackage | |
{ | |
public class installer : ApplicationEventHandler | |
{ | |
protected const string ExampleSectionAlias = "example"; | |
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
// Gets a reference to the section if the section is already added | |
Section section = applicationContext.Services.SectionService.GetByAlias(ExampleSectionAlias); | |
if (section != null) return; | |
//Add a custom Section | |
applicationContext.Services.SectionService.MakeNew("Example", ExampleSectionAlias, "icon-smiley"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment