Skip to content

Instantly share code, notes, and snippets.

@chrismrgn
chrismrgn / AddClaimToADFClaimStore.cs
Last active August 29, 2015 14:05
Add Claim to Ambient Data Framework Claim Store from C#
AmbientDataContext.CurrentClaimStore.Put(new Uri("CLAIM_URI"),
CLAIM_VALUE,
Tridion.ContentDelivery.AmbientData.Runtime.ClaimType.Normal);
@chrismrgn
chrismrgn / AmbientDataFrameworkHttpModule.cs
Last active August 29, 2015 14:06
HTTPModule to add claims to Ambient Data Framework (ADF) Claim Store
using Tridion.ContentDelivery.AmbientData;
namespace Tridion.ADF.Modules.DayOfWeek
{
public class DayOfWeekModule : IHttpModule
{
public DayOfWeekModule() { }
void IHttpModule.Dispose() { }
@chrismrgn
chrismrgn / PageTemplate.cshtml
Created December 30, 2014 23:33
PageTemplate.cshtml
@@model PageViewModel
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h1>@@Model.Title</h1>
<div>
@@if(Model.ComponentPresentations != null)
{
foreach (ComponentPresentation componentPresentation in Model.ComponentPresentations)
@chrismrgn
chrismrgn / ComponentTemplate.cshtml
Created December 30, 2014 23:43
ComponentTemplate.cshtml
@@model ProductsViewModel
</div>
<div>
<h2>@Component.title</h2>
<p>@Component.summary</p>
</div>
@foreach(var product in Component.products)
{
@chrismrgn
chrismrgn / PageContoller.cs
Created December 30, 2014 23:53
PageController.cs
public class PageController : Controller
{
public ActionResult RenderPage(string url)
{
TridionHelper utils = new TridionHelper();
PublicationMeta publicationMeta = utils.GetPublicationMetaByUrl("/");
if (String.IsNullOrEmpty(url))
url = "Index.html";
if (!Path.HasExtension(url))
@chrismrgn
chrismrgn / global.asax.cs
Created December 30, 2014 23:57
global.asax.cs
TridionPathProvider tridionPathProvider = new TridionPathProvider();
HostingEnvironment.RegisterVirtualPathProvider(tridionPathProvider);
@chrismrgn
chrismrgn / TridionPathProvider.cs
Created December 31, 2014 00:03
TridionPathProvider.cs
public class TridionPathProvider : VirtualPathProvider
{
public TridionPathProvider()
: base()
{
}
protected override void Initialize()
{
}
@chrismrgn
chrismrgn / RenderPresentationHelper.cs
Created December 31, 2014 00:09
RenderPresentationHelper.cs
public static MvcHtmlString RenderPresentation(this HtmlHelper html, ComponentPresentation presentation)
{
ComponentMetaFactory componentMetaFactory = new ComponentMetaFactory(presentation.PublicationId);
IComponentMeta componentMeta = componentMetaFactory.GetMeta(string.Format("tcm:{0}-{1}", presentation.PublicationId, presentation.ComponentId));
return html.Action(componentMeta.CustomMeta.GetValue("action").ToString(),
componentMeta.CustomMeta.GetValue("controller").ToString(),
new
{
publicationId = presentation.PublicationId,
@chrismrgn
chrismrgn / BoldItalicTweeter.cs
Last active August 29, 2015 14:12
BoldItalicTweeter.cs
class Program
{
static void Main(string[] args)
{
//Get Articles
string url = @"http://www.thebolditalic.com/articles.rss?page={0}";
var credentials = TwitterCredentials.CreateCredentials("Access_Token", "Access_Token_Secret", "Consumer_Key", "Consumer_Secret");
int count = 0;
int loop = 0;
for (int i = 1; i < 200; i++)
@chrismrgn
chrismrgn / OpenSchema.js
Last active August 29, 2015 14:12
OpenSchema.js
javascript: (function (UI, B, e, a, r, d)
{
if ( typeof String.prototype.endsWith != 'function' ) {
String.prototype.endsWith = function( str ) {
return this.substring( this.length - str.length, this.length ) === str;
}
};
try
{