Skip to content

Instantly share code, notes, and snippets.

View folkertsj's full-sized avatar

Joshua Folkerts folkertsj

View GitHub Profile
@folkertsj
folkertsj / AbstractCacheService.cs
Last active February 11, 2019 23:46
Episerver Forms Mailchimp Integration
using EPiServer.Framework.Cache;
using System;
namespace MailChimpSample.Business.Caching
{
public abstract class AbstractCacheService : ICacheService
{
private static readonly TimeSpan _DefaultCacheDuration;
private static readonly CacheEvictionPolicy _DefaultCacheEvictionPolicy;
// Allows us to define our own Dropdown options from code.(UIHint)
[UIHint("BackgroundPlacementMultiple"), Display(Name = "Background Position", Order = 20, Description = "The background placement for the backgrou image of this block")]
public virtual string BackgroundPlacement { get; set; }
public class BackgroundSelectionFactory : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)
{
var backgroundOptions = new List<SelectItem>();
backgroundOptions.Add(new SelectItem() { Text = "Top Left", Value = "tl" });
@folkertsj
folkertsj / NewVirtualMapping.xml
Created August 11, 2011 14:20
Adding The Virtual Mapping To EPiServer.config
<virtualPath customFileSummary="~/FileSummary.config">
<providers>
<clear />
<add showInFileManager="false" virtualName="CreateNewPage" virtualPath="~/Templates/PageTypeTemplates/Overrides/CreateNewPage.aspx" bypassAccessCheck="false" physicalPath="" name="CreateNewPageMapping" type="EPiServer.Web.Hosting.VirtualPathMappedProvider,EPiServer" />
</providers>
<filters />
</virtualPath>
<!-- virtualPathMappings are used by "VirtualPathMappedProvider". -->
<virtualPathMappings>
<add url="~/secure/CMS/Edit/NewPage.aspx" mappedUrl="~/Templates/PageTypeTemplates/Overrides/CreateNewPage.aspx" />
@folkertsj
folkertsj / NewPageTypeWithPagetypeTab.cs
Created August 11, 2011 14:18
Adding PageTypeTab to the New PageType
[PageTypeTab( Tab=typeof(NewTab))]
[PageType(Filename = "/NewPage.aspx", Name = "Album Page", AvailableInEditMode = true, Description = "This pagetype is of NewPage.")]
public class NewPage : TypedPageData
{
}
@folkertsj
folkertsj / PageTypeTabNewTab.cs
Created August 11, 2011 14:06
Code to create a new PageTypeTab
public class NewTab : PageTypeTab
{
public override string Name
{
get { return "New Tab"; } // name of tab in ui
}
public override int SortIndex
{
get { return 300; } // default is 100
PageData pd = DataFactory.Instance.GetPage(GetSiteStartPage(siteId));
AccessControlList acl = pd.ACL.CreateWritableClone();
acl.Add(new AccessControlEntry(username, AccessLevel.FullAccess));
acl.Remove("Everyone");
new PageAccessControlList(pd.PageLink, acl).Save(SecuritySaveType.RecursiveModify);
var pageTypesList = PageType.List();
foreach (PageType pt in pageTypesList)
{
var defs = pt.Definitions;
var pd = defs.Where(p => p.Name == pageDefinitionName).FirstOrDefault();
if (pd != null)
{
pd.Delete();
}
}
public static void UpdatePageTypeWithGuidProperty()
{
var pageTypesList = PageType.List();
foreach (PageType pt in pageTypesList)
{
var pd = GetNewPageDefinition();
pd.PageTypeID = pt.ID;
pd.Save();
}
}
if (Request.QueryString["id"] != null)
{
if (IsPostBack)
{
var id = Request.QueryString["id"].ToString();
Response.Redirect(string.Format("/secure/CMS/edit/EditPanel.aspx?SelectedEditPanelTab=1&id={0}", id));
}
}