3

Our Environment : SDL Tridion 2013 SP1

We are trying to automate sitemap during every page publishing/unpublishing. The requirement is to create two sitemap files (audiositemap.xml/videositemap.xml). While creating content pages, author would choose whether the page type is audio or video in page metadata.

During publishing/unpublishing, if the page type is audio, url needs to be added in audiositemap.xml file. If it is video type page, it should be added in videositemap.xml.

Can anyone suggest if it can be done through event handler, deployer extension or db customization? Or any other better way.

  • Custom resolver (see Nuno's answer), event handler, deployer extension, or storage extensions are all possibilities. We'd only recommend database customization (or a custom database) if it's part of one of the previous extension points. – Alvin Reyes Jul 21 '16 at 5:39
5

Well, this wouldn't be Tridion if there weren't 15 ways of doing it. My preferred approach for this - given that you already have the sitemap logic built into CM Templates - would be to use a Custom Resolver.

While functionally it can achieve the same as an Event, the reason why I would choose this approach is that it would allow you to add the navigation page in question to the same publish transaction, resulting in slightly better performance than creating one additional transaction, and - because it's in the same transaction - if for any reason the other page fails to publish, so does the navigation page.

| improve this answer | |
3

Welcome the tridion community.

Coming to your question about generating site map using event handler is not good idea, because when you publish in bulk, there will be performance and concurrency issues which are very difficult to handle and if you are able to handle them that will be at the cost of increased publishing time.

The better approach to implement sitemap is through storage extension. You can refer to the link: storage extension

| improve this answer | |
2

This can be achieved using Event system. Only thing if your sitemap is bigger in size it will have some performance effect. But you can try the following:

  1. Write a custom event handler on Page Publish/unpublish and make the phase TransactionCommitted which is suitable for auto publishing trigger. As if the action is a success then only you need to add url in your sitemap and publish it.

  2. Apply your logic to set auto publishing of your sitemap xml based on the value selected in your page metadata (audio/video).

You can try something like below: (not tested)

Itemfields metaDataFields = new ItemFields(page.Metadata, page.MetadataSchema);
SingleLineTextField yourField = (SingleLineTextField)metaDataFields["FieldName"];
if(yourField.Value == "audio")
{
//publish audio sitemap 
}
//else publish video sitemap if value is video

You can refer to this link to get some info on Event System and also see here for the different event phases.

Also check this interesting link on 'best practices to manage the sitemap for a Tridion website'. Let me know if this helps.

| improve this answer | |
1

I will use a similar but slightly different approach to what @Anumap suggested, because I like to keep things decoupled. So, I would create two separate components in Tridion which hold the audio and video sitemap and update them on every publish of a page of type audio or video and then publish the same only if there is a change in the SiteMap.

I will use publish event system asynchronous method of transaction save to get the transaction, find the page object, identify if needed to update sitemap or not and will publish only if there is a new addition to the sitemap components. The method is

EventSystem.SubscribeAsync<PublishTransaction, SaveEventArgs>

This keeps things decoupled and advantage is you publish only when there is a new addition to the sitemap. It will be faster on regular page publish or updates to a page since there will be no change in sitemap, while custom resolver or any other synchronous event will atleast check to see if it needs to make update or not on every publish transaction and will add time to every publish, be it new or existing page publish with modifications.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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