WordPress blogging system

Integrate SDL Tridion with a WEB 2.0 blogtool

In this article we will describe how to integrate a WEB 2.0 tool like a blogtool with SDL Tridion. We will use the blogtool WordPress (http://www.wordpress.com/) as an example, but it could easily be Blogger from Google or any other blogtool.


Let's get started!

Well, what�s needed to get started? A SDL Tridion license would be a good start ;-). 
To get really started you need some �hook� to be able to communicate with your blogtool. In our case (WordPress) there are plenty of hooks available on the web. We choose the .NET �MetaWebLogApi�. Simply put:  this .NET API let�s you call a WordPress page (xmlrpc.php = Remote Procedure Call) with certain parameters.  This way you can create a new post or delete a post by simply calling this page with the correct parameters.


Visualize it!

Now we need to think about the visual aspect of the integration. How do we want it to look? �Where� does the integration take place? We wanted to extend the �Publishing� menu option of Tridion. When users right click on a component an extra option is added to the �Publishing� context-menu item.

Figure 1 - Context-menu extension

To enable this, we�ll need the TCMExtensionInstaller tool from SDL Tridion. This tool let you easily extend the Content Manager GUI.  All it takes to get this done is to create an XML file with the extension information and an XML file with the text for the labels. (For multi-language support). Put this and your extension files into a .ZIP file and the tool does the magic! In short: in the Extension.xml file we defined what should happen if a user clicks on the �Publish to Wordpress� menu-item.  Our extension will call an .aspx page with parameter �uri� holding the current selected component-uri.


Here we go!

Now we are ready to dive into the real extension. That is:  creating the functionality that calls the WordPress xmlrpc page with the correct parameters.  Because the MetaWebLogAPI is a .NET API, we will create a ASP.NET webapplication. 

When you want to use an API you either have a .DLL file or the source code. Because we have the source code,  you can place it into your project. If you however have a DLL file you need to register this DLL file with your project in order to use it. 

After setting up the environment correctly the next step is creating a new post, because that�s what we want.  
In order to create a post we first have to make contact to our blog. Of course the API has objects and methods to accomplish this. We used the following code:

Figure 2 � Create blog object and set connection-settings

In this sample we had to use a proxy object to connect to the blog. This may not be the case in your situation. In that case you can ignore the proxy-part of the connection.

Now we have a nice blog object and we can start using it. Creating a post would be fun, so that�s exactly what we are going to do.

Extending it

Below is a sample of how to create a blog-post using the API:

Figure 3 - Creating and posting a new post

In this sample we use �hardcoded� values. It�s obvious we don�t want it to work this way. We want the value�s of the selected component! Well, that shouldn�t be a problem since we can grab the �uri� parameter -we defined it in the extension, remember?- from the Request object. Once we have that TCM URI we can, by using the .NET Dll�s from SDL Tridion, easily grab the component and do all sort of things with it :-)

Here�s how we grab the component. Be sure to register the necessary SDL Tridion DLL�s to your project!

Figure 4 - Get component object

Voila! Getting the fields from the component is now easy. 

Figure 5 - Get component field values



We outlined just some of the possibilities. Your imagination is the limit. You can freely combine the TOM with the possibilities of the API. You could for instance fill a dropdown with all the different blogs you maintain. Wait�did I hear a question? Yes? �How do I retrieve the list of blogs?� Well, imagine the following scenario:

You want to maintain multiple blogs. You want to use versioning, archiving, �Show where used� and security. All standard Tridion functionality. How could you implement this? Well, easy:

  • Create a structuregroup in a certain publication for which you want a blog (or blogs);
  • Create a page for every blog, set a metadata with the blog properties like: url, password, username, etc. Also define which user(group) is allowed to use this blog;
  • Set a meta-data schema on the publication holding a reference to the blog structuregroup.                

Now, in your extension popup you can grab the component because you know the URI. If you have the component, you can find the publication. If you have the publication, you can read the metadata. You can grab the blog-structuregroup. You can read all �blogs� (pages) from this structuregroup and voila: a list of blogs! 

Put it in a dropdown (or checkboxes, so you can publish to multiple blogs at the same time!). If the user now publishes or deletes the post from a certain blog, you can edit the page-object and add or delete the component from the page. The page is a �view� of your blog.

If you edit the component-template you can also make it look like the real blog.

You also can use the �show where used� on the individual blogposts and you can see which blog (page) is using this post (component).

Also, versioning and archiving of the blog is possible. As I said: your imagination is the limit!

As you have seen it�s  easy to integrate SDL Tridion with WEB 2.0 blogging tool. Especially when there�s an API you can use. All you need to do is to simply reference the API and you�re done.

Final notes

Since this extension is an ASP.NET website and it is installed (by the TCMExtensionInstaller)  in your SDL Tridion Content Manager Website, you have to manually make the newly added directory a virtual directory in your IIS Control Panel.


:    Albert Romkes
:    Brunel ICT
License agreement
Download package
:    web2.0,  blogging,  mashup
:   1.0
:   Yes

About the Author
Albert Romkes
SDL Tridion MVP & Certified SDL Tridion Consultant

Attended the Tridion Academy in 2006 while working for Brunel ICT. Right now I work with SDL Tridion on a daily bases for my own company called Rainology.


Most Popular Building Blocks

These are the most popular Building Blocks. Did you already get them?