8

I'm writing a GUI extension and using the Anquilla framework to get a list of Keywords within a Category. I'm obtaining an XML document for the list of keywords then working with that document within my extension.

My problem is that the returned XML doesn't contain the Keyword's 'Description' value. I have the Title and Key etc.

My original code looks like this:

var category = $models.getItem("CATEGORYTCMID:);
var list = category.getListKeywords();
list.getXml();

A typical node returned is this:

<tcm:Item ID="tcm:4-1749-1024" 
Type="1024" Title="rate_one" Lock="0" IsRoot="true" 
Modified="2012-12-17T23:01:59" FromPub="010 Schema" 
Key="rate_one_value" IsAbstract="false" 
CategoryTitle="TagSelector" 
CategoryID="tcm:4-469-512" Icon="T1024L0P0" 
Allow="268560384" Deny="96" IsNew="false" 
Managed="1024"/></tcm:ListKeywords>

So I've tried using a Filter to give me additional column information:

var filter = new Tridion.ContentManager.ListFilter();
filter.columns = Tridion.Constants.ColumnFilter.EXTENDED;
var list = category.getListKeywords(filter);

Unfortunately this only gives the additional XML attributes:

IsShared="true" IsLocalized="false"

I'd really like the description value to be part of this XML without having to create a Keyword object from the XML. Is such a thing possible?

cough any ideas? cough

Chris Summers
  • 10,153
  • 1
  • 21
  • 46
johnwinter
  • 3,624
  • 15
  • 24

3 Answers3

3

I'm afraid you'll have to load the Keyword itself to get the Description. It's not used in any lists, so it's not returned in the XML.

Peter Kjaer
  • 4,316
  • 13
  • 23
2

You could always create a List Extender to add this information to the list, but try to be smart about it since this extender will execute everytime a GetList is called.

Won't save you from having to open every keyword in the list, but you'll be doing it server-side (with Core Service/NetTcp for instance) which will probably be easier and faster than opening each keyword with Anguilla.

Nuno Linhares
  • 10,214
  • 1
  • 22
  • 42
0

In this instance I only need the one keyword, so I simply get it from the CMS. Getting an object in Anguilla is a bit weird, here's the code:

  1. In your main code area:

       var selectedKy = $models.getItem("TcmUriOfKeywordHere");
       if (selectedKy.isLoaded()) {
         p.selectedKy = selectedKy;
         this.onselectedKyLoaded();
       } else {
         $evt.addEventHandler(selectedKy, "load", this.onselectedKyLoaded);
         selectedKy.load();
       }
    

    It's worth noting how I store the keyword in the properties of the item, so I can obtain it in the onselectedKyLoaded function

  2. The function called once the item is loaded

     ContentBloom.ExampleGuiExtension.prototype.onselectedKyLoaded = function (event) {
         var p = this.properties;
         var selectedDescription = p.selectedKy.getDescription();
         // do what you need to do with the description :)
     };
    

I resolved this, thanks to the answer here: https://stackoverflow.com/a/12805939/1221032 - Cheers Nuno :)

halfer
  • 19,824
  • 17
  • 99
  • 186
johnwinter
  • 3,624
  • 15
  • 24