Skip to content

Instantly share code, notes, and snippets.

private void FixUrlClaim()
{
if (AmbientDataContext.CurrentClaimStore == null)
{
throw new Exception("Ambient Data Framework is not configured. Check there is a cd_ambient_conf.xml file, and the AmbientFrameworkModule HttpModule is configured in web.config");
}
var claims = AmbientDataContext.CurrentClaimStore.GetAll();
var uri = new Uri("taf:request:full_url");
//In order for Audience Manager to work, the ADF must contain a full_url claim with an actual Tridion page URL
// as it uses this to determine publication id and thus other configuration
@willprice76
willprice76 / PublishTransactionCache.cs
Created April 29, 2016 12:05
Extension methods on Tridion.ContentManager.Templating.PublishingContext to allow caching of items between render actions in a publish transaction
using System;
using System.Collections.Generic;
using System.Runtime.Caching;
using Tridion.ContentManager.Templating;
namespace Tridion.Extensions.Templating
{
/// <summary>
/// Extension methods on the Tridion.ContentManager.Templating.PublishingContext class to allow
/// for caching of arbitrary objects, package items and rendered output between
@willprice76
willprice76 / SmartTargetSecurityExtender.Model.xml
Last active November 24, 2015 09:29
Editor config for SmartTarget Security GUI Extension
<?xml version="1.0"?>
<Configuration xmlns="http://www.sdltridion.com/2009/GUI/Configuration/Merge"
xmlns:cfg="http://www.sdltridion.com/2009/GUI/Configuration"
xmlns:ext="http://www.sdltridion.com/2009/GUI/extensions">
<resources>
<cfg:groups />
</resources>
<definitionfiles/>
<extensions>
<ext:editorextensions />
@willprice76
willprice76 / SmartTargetSecurityExtender.cs
Last active November 23, 2015 23:29
Update to Simple Data Extender to take into account Group membership
public override XmlTextReader ProcessResponse(XmlTextReader reader, PipelineContext context)
{
var command = context.Parameters["command"] as String;
command = command.ToLower();
if (command == "getpromotions" || command == "getregions")
{
UserData currentUser = new CoreServiceHelper(System.Web.HttpContext.Current.User.Identity.Name).GetCurrentUser();
if (currentUser.Privileges != 1) //Skip for Admins
{
List<String> data = GetRegionPrefixesForUser(currentUser);
@willprice76
willprice76 / SimpleSecurityExtender.cs
Last active November 23, 2015 23:27
Simple Example Data Extender for implementing security on Tridion SmartTarget Promotion Management
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Tridion.Web.UI.Core.Extensibility;
namespace SmartTargetGUIExtensions
{
@willprice76
willprice76 / component_presentations.extended.xml
Created September 1, 2015 14:30
Example extended SmartTarget Component presentation XML from transport package
<ComponentPresentations>
<ComponentPresentation IsRendered="true">
<Component Id="tcm:100-10265" />
<CodePage>65001</CodePage>
<Template Id="tcm:100-10119-32" Priority="200" Format="HTML Fragment" Title="Promotion - JSON" IsDynamic="false" />
<RenderingMetadata>
<SmartTarget>
<Component path="\Building Blocks\Content\Banner\" tcmuripath="\tcm:100-13-2\tcm:100-19-2\tcm:100-122-2">
<Keyword id="tcm:100-10445-1024" tcmuripath="\tcm:100-5390-512\tcm:100-10445-1024" titlepath="\Segment\Games" categoryId="tcm:100-5390-512" categoryTitle="Segment" categoryXmlName="Segment" />
<Source>
@willprice76
willprice76 / component_presentations.xml
Created September 1, 2015 14:28
Example SmartTarget metadata for DCPs in publish package
<ComponentPresentations>
<ComponentPresentation IsRendered="true">
<Component Id="tcm:100-10265" />
<CodePage>65001</CodePage>
<Template Id="tcm:100-10119-32" Priority="200" Format="HTML Fragment" Title="Promotion - JSON" IsDynamic="false" />
<RenderingMetadata>
<SmartTarget>
<Component path="\Building Blocks\Content\Banner\" tcmuripath="\tcm:100-13-2\tcm:100-19-2\tcm:100-122-2">
<Keyword id="tcm:100-10445-1024" tcmuripath="\tcm:100-5390-512\tcm:100-10445-1024" titlepath="\Segment\Games" categoryId="tcm:100-5390-512" categoryTitle="Segment" categoryXmlName="Segment" />
<Source>
@willprice76
willprice76 / Example.SmartTarget.Renderer.cs
Last active September 1, 2015 15:07
Custom Renderer to Extend SmartTarget indexing metadata to include Keyword Key
using System;
using System.Xml;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Rendering;
using Tridion.ContentManager.Publishing.Resolving;
namespace Example.SmartTarget
{
@willprice76
willprice76 / EditableAjaxContent.js
Last active August 29, 2015 14:17
Simple Javascript example to illustrate AJAX loaded content being editable in XPM
// Load test HTML content client side
$( document).ready(function() {
loadContent("dynamic-test","/dynamic.htm");
});
//Load content from a URL into the specified HTML element
function loadContent(elementId,url) {
$("#" + elementId).load(url, function () {
startXpm("http://my-cms-url");
});
@willprice76
willprice76 / cd_ambient_conf.xml
Last active August 29, 2015 14:13
cd_ambient_conf Cartridges example
<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Version="6.1"
xsi:noNamespaceSchemaLocation="../../schemas/cd_ambient_conf.xsd">
<Cartridges>
<Cartridge File="cd_webservice_preview_cartridge.xml"/>
<Cartridge File="cwd_engine_cartridge_conf.xml"/>
<Cartridge File="smarttarget_cartridge_conf.xml"/>
<Cartridge File="session_cartridge_conf.xml"/>