13

I know there is a command line interface to Content Porter. Can this be used to move commonly changed items (e.g. CSS or Javascript) between say a DEV and TEST environments?

I have managed to get a basic scenario to work but I had to manually create the settings files for import and export using Content Porter and then call a script like the following:

<!-- language: lang-none -->
@echo off

SET cproot="C:\Documents and Settings\rsleggett\Local Settings\Apps\2.0\XWVXZKY2.HEP\MV5DNY4J.EY9\cp.a..tion_51a0337025653ee3_0003.0001_37f2b7f83cbbdc3d"

ECHO Styles and Scripts Content Port

ECHO Enter your username

SET /p Username=

ECHO Enter your password

SET /p Password=

ECHO Attempting content port..

call %cproot%\cpcmd /Config:export.xml /User:%Username% /Password:%Password%

call %cproot%\cpcmd /Config:import.xml /User:%Username% /Password:%Password%

Would it be possible to say "all items in a given folder"? E.g. would my export.xml file maintain the fact that I checked the parent, or does that specifically select children which are then included in my export.xml?

1
  • Good question .
    – Mr Smith
    Commented Mar 7, 2013 at 19:05

1 Answer 1

6

Some years ago I had to deal with a scenario where I had to automate the export of the results of a Search Folder (this was before Content Porter supported this), so I wrote a library to create the CP export (& import) configuration files based on a webdav URL.

This was written in 2009/2010, so it's fully based on the deprecated Business Connector - I won't be sharing that part of the code - but I used this class to generate the XML for me. Be aware that the Content Porter Configuration xml format is not public, and Tridion may change it in future versions.

The class is available for download here (google login required) and it's not something I am proud of :-) it got the job done.

This is how you would use it, from an app that finds the items to add to the Export.

  • Create a ContentPorterXmlManager object:
ContentPorterXmlManager exportManager = new ContentPorterXmlManager(locationWhereToCreateFile, 
                                            ExportOrImportAction, 
                                            serverName, ExportFromOwningPublication?, "", false);

ExportFromOwningPublication is a bool that you can use to tell this class to use the Owning Publication of the object instead of its current context - very useful option.

As you find TCM objects that you want to add to this export or import file, add them with

exportManager.AddBrowserItemByWebdavUrl(webdavUrl, recursive?);

And finally, when done, save the config:

exportManager.CurrentConfig().Save("PathToFile");

You will likely have to change quite a lot in here to get it to work properly with CoreService, but the XML generation part should still work fine.

1
  • +1. So it looks like Nuno implies, "no, you can only export the folder contents at the time of export." As a follow-up, Content Porter 2009 SP2 added the ability to export Search Folder results in addition to the definitions. A bit early for it, but apparently with SDL Tridion 2013, you might consider Bundles, another type of Virtual Folder, to help with Content Ports. Commented Mar 7, 2013 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.