Skip to content

Instantly share code, notes, and snippets.

View rsleggett's full-sized avatar

Rob Stevenson-Leggett rsleggett

View GitHub Profile
@rsleggett
rsleggett / gist:2424107
Created April 19, 2012 20:52
Tridion Dreamweaver Template conditionally render when when using Component Presentations Grouped by Name TBB
<!-- TemplateBeginIf code="ComponentTemplateNameCPsCount > 0" -->
<!-- TemplateBeginRepeat name="ComponentTemplateNameCPs" -->
RenderComponentPresentation()
<!-- TemplatEndRepeat -->
<!-- TemplateEndIf-->
@rsleggett
rsleggett / gist:2477507
Created April 24, 2012 07:34
XSLT Choose When (else if)
<xsl:choose>
<xsl:when test="$someValue = 1">
<xsl:value-of select="someXpath" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="defaultXpath" />
</xsl:otherwise>
</xsl:choose>
@rsleggett
rsleggett / gist:2487756
Created April 25, 2012 07:29
Simple TBB for replacing Label delimiters
//The alternative uses $$Label$$
const string pattern = @"\$\$([A-Za-z0-9_-]+)\$\$";
//Replacement regex for %%Label%%
const string replacement = "%%$1%%";
Item output = package.GetByName(Package.OutputName);
string outputString = Regex.Replace(output.GetAsString(), pattern, replacement);
output.SetAsString(outputString);
package.PushItem(Package.OutputName, output);
@rsleggett
rsleggett / broker.xml
Created October 11, 2012 08:06
Broker configuration for database
<Storage Type="persistence" Id="defaultdb" dialect="MSSQL" Class="com.tridion.storage.persistence.JPADAOFactory">
<Pool Type="jdbc" Size="5" MonitorInterval="60" IdleTimeout="120" CheckoutTimeout="120" />
<DataSource Class="com.microsoft.sqlserver.jdbc.SQLServerDataSource">
<Property Name="serverName" Value="YOURSERVER" />
<Property Name="portNumber" Value="1433" />
<Property Name="databaseName" Value="YourDatabase" />
<Property Name="user" Value="YourUser" />
<Property Name="password" Value="*****" />
</DataSource>
</Storage>
@rsleggett
rsleggett / broker_publication.xml
Created October 11, 2012 08:11
Publication settings for the broker
<Publication Id="42" defaultStorageId="MSSQL_01" cached="false">
<Item typeMapping="Binary" itemExtension=".jpg" storageId="defaultFile" cached="true"/>
<Item typeMapping="Binary" itemExtension=".gif" storageId="defaultFile" cached="true"/>
<Item typeMapping="Binary" itemExtension=".pdf" storageId="defaultFile" cached="true"/>
<Item typeMapping="Binary" itemExtension=".jpeg" storageId="defaultFile" cached="true"/>
<Item typeMapping="Binary" itemExtension=".png" storageId="defaultFile" cached="true"/>
<Item typeMapping="Binary" itemExtension=".ico" storageId="defaultFile" cached="true"/>
</Publication>
@rsleggett
rsleggett / gist:3870935
Created October 11, 2012 08:16
Default storage ID
<ItemTypes defaultStorageId="defaultdb" cached="false">
<!-- Broker config stuff -->
</ItemTypes>
@rsleggett
rsleggett / embedded_resource.cs
Created October 21, 2012 16:27
How to add schema as embedded resource
[TcmTemplateTitle("Build ASP.NET Sitemap File from Taxonomy")]
[TcmTemplateParameterSchema("resource:BuildingBlocks.Tridion.ModularTemplates.Resources.Build Sitemap from Taxonomy Parameter Schema.xsd")]
public class BuildSitemapFromTaxonomy : Base.TemplateBase
{
//Code snipped
}
@rsleggett
rsleggett / _Layout.cshtml
Created October 22, 2012 17:58
Basic Layout
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>_Layout.cshtml</title>
</head>
<body>
<header><h1>Welcome to DD4T</h1></header>
<div>
@RenderBody()
@rsleggett
rsleggett / Landing.cshtml
Created October 22, 2012 18:02
Basic DD4T page template
@model DD4T.ContentModel.IPage
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h1>Hello from landing page: @Model.Title</h1>
<ul>
<li>I live in: @Model.StructureGroup.Title</li>
<li>I have @Model.ComponentPresentations.Count component presentations</li>
@rsleggett
rsleggett / NinjectDependencyResolver.cs
Created October 22, 2012 21:27
Here's a ninject dependency resolver
namespace DD4T.Web.Mvc.Ninject
{
///<summary>
/// NinjectDependencyResolver
/// 2012-10-22
/// Author: Robert Stevenson-Leggett
///</summary>
public class NinjectDependencyResolver : IDependencyResolver
{
private readonly IKernel _kernel;