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
@DominicCronin
DominicCronin / gist:9089062
Created February 19, 2014 09:55
execute export and import
$impexp = get-ImportExportServiceClient
$contentFolderSelection = new-object SubTreeSelection "tcm:3-1005-2",$false
$exportInstruction = new-object ExportInstruction
$exportInstruction.BluePrintMode = [BluePrintMode]::ExportSharedItemsFromOwningPublication
($processId = $impexp.StartExport( @($contentFolderSelection),$exportInstruction))
WaitForImportExportFinish $impexp $processId
DownloadPackageToFile $processId "package.zip"
$uploadId = UploadPackageFromFile "package.zip"
@DominicCronin
DominicCronin / gist:9088961
Created February 19, 2014 09:46
get-ImportExportServiceClient
function get-ImportExportServiceClient {
param(
[parameter(Mandatory=$false)]
[AllowNull()]
[ValidateSet("Service","Upload","Download")]
[string]$type="Service"
)
InitImportExport
$binding = new-object System.ServiceModel.BasicHttpBinding
@DominicCronin
DominicCronin / gist:9088882
Created February 19, 2014 09:40
ImportExport.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ImportExport_basicHttpBinding" maxReceivedMessageSize="41943040">
<readerQuotas maxStringContentLength="41943040" maxArrayLength="41943040" />
<security mode="TransportCredentialOnly">
<!-- For LDAP or SSO authentication of transport credentials, use clientCredentialType="None" -->
<transport clientCredentialType="Windows" />
@DominicCronin
DominicCronin / gist:9088693
Last active August 29, 2015 13:56
Init ImportExport
function InitImportExport{
if (-not $global:ImportExportIsInitialized) {
Add-Type -assemblyName System.ServiceModel
Add-Type -Path 'C:\Program Files (x86)\Tridion\bin\client\ImportExport\Tridion.ContentManager.ImportExport.Client.dll'
Add-Type -Path 'C:\Program Files (x86)\Tridion\bin\client\ImportExport\Tridion.ContentManager.ImportExport.Common.dll'
Import-Module Reflection
Import-Namespace Tridion.ContentManager.ImportExport
Import-Namespace Tridion.ContentManager.ImportExport.Client
$global:ImportExportIsInitialized = $true
}
@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
@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 / 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: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: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" -->