Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a category's child keywords when using XSLT component template

Tags:

tridion

During a recent upgrade from Tridion 2009 to 2011 part of an XSLT component template stopped working.

The component template read the child keywords from the categoryXSD section of the current publication XML. Then used webdav to load each keyword.

It appears that this section of the publication XML has been removed in 2011.

Does anyone know another method of getting the child keywords from a Category Tcm Id when using XSLT templating?

like image 307
Mark Cooper Avatar asked Apr 18 '12 14:04

Mark Cooper


2 Answers

I'm looking at the Publication XML, I think you are not in luck. There is a mention to <tcm:CategoriesXSD>, and you can get the Category TcmUri from it, but if you navigate to the Category XML, there is no mention of its child Keywords in there.

So, either use the XSLT Mediator, as Chris suggests, or rewrite this XSLT as a C# template.

like image 27
Mihai Cădariu Avatar answered Oct 21 '22 16:10

Mihai Cădariu


If I need lists of items when using the older style XSLT Component Templates I normally make a "Helper" Service or ASPX page which returns an XML document containing the relevant items. You can then call that helper using the Document() function in XSLT. Typically this takes the form of a ASPX stored on the CMS Service at something like http://tridion.local.url/web/helpers/GetListXml.aspx?uri=SomeOrgItemURI

You can use the TOM API in GetListXml.aspx to query the item using the GetListItem and write the response to the output.

Then in your XSLT you can use something like <xsl:variable name="KEYWORDS" select="document('http://tridion.local.url/web/helpers/GetListXml.aspx?uri=$CAT_URI')"/>. You can then iterate through the Keyword node in the new variable.

However none of that in necessary if you use Modular Templates and the XSLT Mediator available on SDL Tridion World as there are many helpers are built in. I strongly recommend considering the newer template techniques, they have a lot to offer.

like image 121
Chris Summers Avatar answered Oct 21 '22 17:10

Chris Summers