Skip to content

Instantly share code, notes, and snippets.

View adamjenkin's full-sized avatar

Adam Jenkin adamjenkin

  • zone
  • Bristol, UK
View GitHub Profile
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Linq" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
public override Basket GetBasket(bool create)
{
// Member is not logged on use default behavior
if (!Member.IsLoggedOn()) return base.GetBasket(create);
// Otherwise try and load a basket for the current member, create one if it doesn't exist
Basket basket = GetBasketForCurrentMember();
if(basket == null)
{
@adamjenkin
adamjenkin / rewrite.xml
Last active December 12, 2015 00:08
IIS Rule for serving a deny robots.txt file based on domain name
<rule name="DenyRobots" stopProcessing="true" enabled="true">
<match url="robots.txt" />
<action type="Rewrite" url="/robots-deny.txt" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www.)?content.company.com" />
</conditions>
</rule>
@adamjenkin
adamjenkin / gist:3402757
Created August 20, 2012 09:54
FilterPublicAccess - Filter for EPiSiteMap
namespace Auros.EPiSiteMap.Filters
{
/// <summary>
/// Filters pages which do-not have public access
/// </summary>
[SiteMapFilter]
public class FilterPublicAccess : EPiServer.Filters.PageFilterBase
{
public override bool ShouldFilter(EPiServer.Core.PageData page)
{
@adamjenkin
adamjenkin / gist:3303287
Created August 9, 2012 11:05
PTB - Enable support for container pages
protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
{
IPageType pageType = PageTypeRepository.CreateNew();
PageTypeAttribute attribute = definition.Attribute;
string name = attribute.Name;
if (name == null)
{
@adamjenkin
adamjenkin / gist:3236610
Created August 2, 2012 12:12
PTB UI - Duplicate validation messages fix
public override void ApplyEditChanges()
{
if (_propertyControls == null)
return;
foreach (IPropertyControl propertyControl in _propertyControls)
{
bool propertyStringControl = false;
try
@adamjenkin
adamjenkin / gist:1582484
Created January 9, 2012 10:54
Umbraco Razor Issue
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using System.Linq
@{
// Get the hompage node
var homepage = @Model.AncestorOrSelf("Start");
}
@adamjenkin
adamjenkin / ACMObjectHelpers.cs
Created December 8, 2011 14:27
Example of getting alt text
public static class ACMObjectHelpers
{
/// <summary>
/// The logger for the class.
/// </summary>
private static ILog Logger = LogManager.GetLogger("IItemHelpers");
/// <summary>
/// Fetches the alt text for the image from the specified path.
/// </summary>
@adamjenkin
adamjenkin / gist:1188405
Created September 2, 2011 11:23
vmb-flv-player-snippet
<div id="flvplayer_div"></div>
<script type="text/javascript">
<!--
var flashvars = {};
//Video width
flashvars.stageW = 512;
//Video height
flashvars.stageH = 288;
//Show preview image?
flashvars.showPreviewImage = true;
@adamjenkin
adamjenkin / gist:1133597
Created August 9, 2011 08:19
Page Output Cache Example
<caching>
<outputCache enableOutputCache="true" enableFragmentCache="true" sendCacheControlHeader="false" omitVaryStar="true"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="StaticPage" duration="86400" varyByParam="*" location="Any" />
<add name="DynamicPage" duration="3600" varyByParam="*" location="Any" />
<!-- A 1 minute cache for the landing pages, if we need it -->
<add name="LandingPage" duration="60" varyByParam="*" location="Any" />
</outputCacheProfiles>
</outputCacheSettings>