4

I am using category.GetListKeywords(KeywordsFilter) to get the keyword list of a category. The fetched keyword list xml looks like below:

<tcm:ListKeywords xmlns:tcm="http://www.tridion.com/ContentManager/5.0" Managed="0">
<tcm:Item ID="tcm:6-5256-1024" Title="Level1 - Test Keyword1" Allow="268560384" Deny="96" Icon="T1024L0P0" Type="1024" IsNew="false" Modified="2015-05-05T11:14:20" IsShared="false" IsLocalized="false" Lock="0" Key="" IsAbstract="false" IsRoot="true" CategoryID="tcm:6-5039-512" CategoryTitle="Test Category"/>
</tcm:ListKeywords>

But the item element for keyword missing the "Description" field.

Is there any way to get "Description" as an attribute of the xml element?

2

It would appear that you can't... I tried using this to get Tridion to return the full objects, but it will not return the description. This unfortunately happens a lot with their API. you tell it to get the full object and SDL thinks it's helping you by saving bandwidth by returning a "lightweight" result. The only option is to get the lightweight version and then requery to get a full object.

$filter = New-Object Tridion.ContentManager.CoreService.Client.OrganizationalItemItemsFilterData
$filter.BaseColumns = 3
| improve this answer | |
  • 3
    This answer would be so much better without the snark :D – Peter Kjaer May 6 '15 at 7:19
  • 1
    actually, if I'm not mistaken, a pretty high-ranking SDL-er pretty much stated the above to me. – Warner Soditus May 6 '15 at 14:00
  • If you want to know the real reason why mosts list return partially loaded objects, you may want to take a look at the DB Stored Procedures for getting the list data and those for reading an individual item (and then imagine combining both is a single humongous one without driving yourself and the query optimizer crazy :-) – Rick Pannekoek May 6 '15 at 20:38
  • Also note that many filters support "additional columns" (filter properties named "IncludeXYZColumn") next to "base columns". In particular: IncludeDescription is such an additional column on some filters. Not sure if it applies to this filter, though. – Rick Pannekoek May 6 '15 at 20:42
  • @Rick Pannekoek: it does not include that option. only one like that is IncludeAllowedActionsColumns. – Warner Soditus May 7 '15 at 14:28
1

Using TOM.NET API, we can get description field of a keyword. Sample code below:

TcmUri categoryURI = new TcmUri(itemId, ItemType.Category, Publication.Id.ItemId);
Category category = Engine.GetObject(categoryURI) as Category;
IList<Keyword> keywords = category.GetKeywords().ToList();
foreach (Keyword keyword in keywords)
{
//keyword.Description
}
| improve this answer | |
  • Murali, I want to fetch the XML list of keywords (under a category), not the keyword objects. Fetching keyword objects is not a good idea considering performance. – Saurabh Gangwar Feb 29 '16 at 6:15
0

Using CoreService you can get the keywords list xml within a category which also has the description. It comes as "comment" attribute/property in the xml that comes back from CoreService. The below line of code will bring the xml with all keyword fields

var keywordList = coreserviceclient.GetListXml(ID, taxonomyFilter);

where ID can be the publication ID of the category and taxonomy filter can be set for the category for which keywords are needed

| improve this answer | |
  • Okay, but i want it in templating TOM.NET code. I think i can use coreservice in templating but not sure if its the right way to achive it. – Saurabh Gangwar May 6 '15 at 10:20
  • 1
    Using the Core Service in templating code is indeed not a good idea. But note that the Core Service is a Service Layer built on top of the TOM.NET API. So that means that all functionality exposed in the Core Service is also available in the TOM.NET. In case of list, the filter type will help you find the associated TOM.NET method. – Rick Pannekoek May 6 '15 at 20:21

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.