Skip to content

Instantly share code, notes, and snippets.

View DominicCronin's full-sized avatar
💭
Still Upskilling on Azure DevOps.

Dominic Cronin DominicCronin

💭
Still Upskilling on Azure DevOps.
View GitHub Profile
@foreach (var cp in Model.ComponentPresentations.Where(cp => cp.RenderData.View == "ContentBlock"))
{
@Html.Render(cp)
}
[ComponentPresentations]
public List<IRenderableViewModel> ComponentPresentations { get; set; }
@DominicCronin
DominicCronin / gist:6776134
Created October 1, 2013 09:48
Example of Tridion Razor templating
<div class=”@Component.Fields.NewsStyle”>
<img src=”@Fields.HeaderImage.ID” alt=”@Fields.HeaderImage.AltText” />
@* Note that Fields is just a shortcut to Component.Fields *@
<h2>@Fields.Header</h2>
<h5>@Fields.NewsDate.ToString(“dd/MM/yy hh:mm”)</h5>
<div class=”body-text”>
@Fields.BodyText
</div>
<ul>
@* Now we'll loop over a ComponentLink field and grab the component title and a field *@
@DominicCronin
DominicCronin / gist:6776110
Last active December 24, 2015 09:19
Example of Tridion XSLT templating
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$content/linkitem:link_component">
<xsl:apply-templates select="$content/linkitem:link_component">
<xsl:with-param name="linktitle" select="$link_title"/>
<xsl:with-param name="linktext" select="$linktext"/>
<xsl:with-param name="linkclass" select="$linkclass"/>
</xsl:apply-templates>
@DominicCronin
DominicCronin / gist:6775961
Created October 1, 2013 09:27
Example of Tridion Dreamweaver templating
<!-- TemplateBeginRepeat name="Component.Fields" -->
@@Field.Name@@
<!-- TemplateBeginRepeat name="Field.Values" -->
<!-- TemplateBeginIf cond="Field.ContentType = 'text/plain'" -->
@@RenderComponentField(FieldPath, TemplateRepeatIndex)@@
<!-- TemplateEndIf -->
<!-- TemplateBeginIf cond="Field.ContentType = 'tridion/field'" -->
<!-- TemplateBeginRepeat name="Field.Fields" -->
@@Field.Name@@
<!-- TemplateBeginRepeat name="Field.Values" -->
@DominicCronin
DominicCronin / gist:6775796
Created October 1, 2013 09:09
Example of Tridion dreamweaver templating
<!-- TemplateBeginRepeat name="Component.Fields" -->
@@Field.Name@@
<!-- TemplateBeginRepeat name="Field.Values" -->
<!-- TemplateBeginIf cond="Field.ContentType = 'text/plain'" -->
@@RenderComponentField(FieldPath, TemplateRepeatIndex)@@
<!-- TemplateEndIf -->
<!-- TemplateBeginIf cond="Field.ContentType = 'tridion/field'" -->
<!-- TemplateBeginRepeat name="Field.Fields" -->
@@Field.Name@@
<!-- TemplateBeginRepeat name="Field.Values" -->
@DominicCronin
DominicCronin / gist:fcc3397a21bda19f4cb8
Created January 13, 2015 10:46
Add Component Id to Binary Filename
// componentUri is a TcmUri representing the id of the binary component that you want to publish
// This snippet shows how you can add the item id to the filename.
var component = (Component)engine.GetObject(componentUri);
var filename = component.BinaryContent.Filename
extension = Path.GetExtension(filename);
filename = Path.GetFileNameWithoutExtension(filename);
filename = String.Concat(filename, "_", componentUri.ItemId.ToString(), extension);
engine.AddBinary(component.Id, null, null, component.BinaryContent.GetByteArray(), filename);
@DominicCronin
DominicCronin / gist:a5b871362921a408c8ef
Created January 13, 2015 10:25
Suffix Binaries With Id
[TcmTemplateTitle("SuffixBinariesWithId")]
public class SuffixBinariesWithId: ITemplate
{
public void Transform(Engine engine, Package package)
{
string paramMimeTypesToMatch = package.GetValue("mimeTypesToMatch");
// match all image types by default
string mimeTypesToMatch = "image/*";
if (!string.IsNullOrWhiteSpace(paramMimeTypesToMatch))
{
@DominicCronin
DominicCronin / gist:786e8b00d21c538b1de5
Created November 4, 2014 21:41
Create Tridion Publications
# Depends on Tridion Powershell Modules (http://code.google.com/p/tridion-powershell-modules/)
function createPublication {
Param(
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
$core,
[parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]$title,
@DominicCronin
DominicCronin / TridionPermissions
Created March 21, 2014 13:53
addRightsAndPermissions
# Depends on PowerShell Reflection module (http://poshcode.org/search/Reflection)
# Depends on Tridion Powershell Modules (http://code.google.com/p/tridion-powershell-modules/)
$autoLocalize = $true
import-module Tridion-CoreService
$core = Get-TridionCoreServiceClient
import-module Reflection
import-namespace Tridion.ContentManager.CoreService.Client