CategorySDL Tridion

SDL Tridion: move items across Publications

This is a quick tip for something that can create a lot of hassle sometimes. As you may be aware of, it’s impossible to copy/paste items across Publications. One option would be to create them manually, but what if they’re too many?
Another option is to use the Content Porter. Right, the Content Porter.
Few steps:
1) Rename the target Publication to whatever temp name you like
2) Rename the source Publication as the target one
3) Launch the Content Porter, select the renamed source Publication, pick the items and export
4) Rename back both the Publications to the original names
5) Launch the Content Porter select the target Publication and import the package.


SDL Tridion: how to get WebDAV url of an item

Suppose you have to reference an item and you don’t want to use the id. Or maybe you just need the full path. One simple way is to edit the item, go  to the Info tab and get it’s location:
how to get WebDAV url of an item

you should have something like this:

[csharp]\910 Design HTML\Building Blocks\System\Templates\Assemblies[/csharp]

just add /webdav/ at the beginning, revert the slashes and add the filename along with the extension:

[csharp]/webdav/910 Design HTML/Building Blocks/System/Templates/Assemblies/Page Revision Date.xsd[/csharp]

SDL Tridion: how to reference a parameter schema

This is going to be my first post on SDL Tridion and I’m going to explain different ways to reference a parameter schema from a ITemplate implementation using the TcmTemplateParameterSchema class attribute.

So, assuming you are creating a nice .NET assembly with your Template Building Blocks and you want to reference a schema, here’s how you could do:

Way #1: direct reference using the ID

1) In the CMS create a Parameters Schema and take the id ( something like “tcm:73-7323-8” )

2) add the class attribute to your ITemplate implementation, BUT change the id of the folder to 0:

public class PageRevisionDate : ITemplate {

this is why the uploader is trying somehow to reference the schema in the same destination folder of the assembly first. If you don’t replace the 0, the upload will fail 🙂

Way #2:  embed the schema as a resource

I found this method on Rob Stevenson-Leggett’s blog, so I just link it. There’s also a repo on GitHub so go and take a look 😀

One thing I don’t like of Way #1 is that you’re hardcoding the id of the schema. Hardcoding’s a big no-no in big project so we need to find another way. Way #2 instead forces you to create the schema in the CMS, copy/paste the xsd in Visual Studio and update it each time you make some changes to the schema. I’m a lazy guy so I really want a better way. And here we get Way #3!

Way #3:  reference an existing schema using webdav url

Let’s start with the drawbacks first: the only real requirement with this approach is that you have to create the schema in the same folder where you’re uploading the assembly. This may be not an issue, depends on how you have architectured your project.

All you need to do is to create the schema as before (remember the directory thing), take it’s WebDAV url and use it as a parameter for the class attribute:

[TcmTemplateParameterSchema(@"/webdav/910 Design HTML/Building Blocks/System/Templates/Assemblies/Page Revision Date.xsd")]
public class PageRevisionDate : ITemplate {

Here we go!

© 2019 Davide Guida

Theme by Anders NorenUp ↑