Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@willprice76
willprice76 / MirrorOnStagingEvent.cs
Last active August 29, 2015 13:57
How to mirror live Tridion publish actions on staging using the Event System
using System;
using System.Linq;
using System.Collections.Generic;
using Tridion.ContentManager.CommunicationManagement;
using Tridion.ContentManager.ContentManagement;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
namespace Example.Events
{
@willprice76
willprice76 / DeleteMasterPublishTransactions.cs
Created March 19, 2014 10:56
SDL Tridion Event handler to allow you to publish in child publications without publishing from the parent. Note that this approach can lead to Warning messages in the event log, if this is a problem then you need a combined event/resolver solution: see https://gist.github.com/willprice76/9664092
using System;
using System.Collections.Generic;
using Tridion.ContentManager.Extensibility;
using Tridion.ContentManager.Extensibility.Events;
using Tridion.ContentManager.Publishing;
namespace Example.Events
{
[TcmExtension("Publish Events Example")]
public class Events : TcmExtension
@willprice76
willprice76 / ClearMasterTransactionResolver.cs
Created March 20, 2014 13:47
Clear all items from a publish transaction for a certain publication. This can be used to implement publish in child publications functionality without publishing content in the parent (master) publication. See https://gist.github.com/willprice76/9639405 for a start point, you will want to put a check to see if the status is Success before delet…
using System;
using System.Collections.Generic;
using Tridion.ContentManager;
using Tridion.ContentManager.Publishing;
using Tridion.ContentManager.Publishing.Resolving;
namespace Example.Resolvers
{
/// <summary>
/// Example resolver to clear all items from publish transactions in certain publications. This can be used as is, or in combination with the
@willprice76
willprice76 / field-helpers.cshtml
Last active August 29, 2015 14:01
Field Helper functions for the Razor Mediator for Tridion
@using Tridion.ContentManager.Templating.Expression
@using Tridion.ContentManager.ContentManagement
@using Tridion.Extensions.Mediators.Razor.Models
@* --------------- IDENTIFYING FIELDS ---------------------- *@
@helper FieldStartMarker(string fieldExpression)
{
var fn = new BuiltInFunctions(TridionHelper.Engine, TridionHelper.Package);
@fn.FieldStartMarker(fieldExpression)
@willprice76
willprice76 / si4t-storage-config.xml
Created May 14, 2014 12:46
SI4T Storage Configuration Snippet
<Storages>
<StorageBindings>
<Bundle src="SearchDAOBundle.xml"/>
</StorageBindings>
<Storage Type="persistence" Id="defaultdb" dialect="MSSQL" Class="com.tridion.storage.si4t.JPASearchDAOFactory">
<!--...Pool and DataSource elements as usual…-->
<Indexer Class="org.si4t.solr.SolrIndexer" DefaultCoreUrl="http://localhost:8080/solr/collection1" Mode="http" DocExtensions="pdf"/>
</Storage>
</Storages>
<div class="row">
<div class="col-sm-3">
<!-- left nav here, uses 1/4 screen width-->
</div>
<div class="col-sm-9">
<!-- main content, uses 3/4 screen width-->
<div class="row">
<div class="col-sm-6"><!-- half width column layout --></div>
<div class="col-sm-6"><!-- half width column layout --></div>
</div>
<h2>Full width image with aspect ratio of 3.3</h2>
<img width="100%" src="/cid/scale/1024x311/source/site/media/abc_tcm8-759.JPG">
<h2>Half width image with default aspect ratio (1.62)</h2>
<img width="50%" src="/cid/scale/512x316/source/site/media/abc_tcm8-759.JPG">
<h2>Fixed width image (150 px) with aspect ratio of 1</h2>
<img width="150px" src="/cid/scale/150x150/source/site/media/abc_tcm8-759.JPG">
<h2>Full width image with custom css class</h2>
<img width="100%" class="my-css-class" src="/cid/scale/1024x632/source/site/media/abc_tcm8-759.JPG">
<h2>Full width image with aspect ratio of 3.3</h2>
@Html.Media(Model.Image, 3.3)
<h2>Half width image with default aspect ratio (1.62)</h2>
@Html.Media(Model.Image,"50%")
<h2>Fixed width image (150 px) with aspect ratio of 1</h2>
@Html.Media(Model.Image,"150px", 1)
<h2>Full width image with custom css class</h2>
@Html.Media(Model.Image,"100%","my-css-class")
@willprice76
willprice76 / ExampleTRIDataController.cs
Last active August 29, 2015 14:07
Example Tridion Reference Implementation Data Controller
using Sdl.Web.Common.Interfaces;
using Sdl.Web.Common.Logging;
using Sdl.Web.Common.Models;
using Sdl.Web.Mvc.Controllers;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
@willprice76
willprice76 / TriJsonDataRouteWithArea.cs
Last active August 29, 2015 14:07
Tridion Reference Implementation JSON Data Controller example route (with Area)
//JSON data route (when DataController is the area "Data")
routes.MapRoute(
"JSON",
"json/{*pageUrl}",
new { controller = "Data", action = "Json" }
).DataTokens.Add("area", "Data");