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

4

3 回答 3

3

恐怕您必须加载关键字本身才能获得说明。它未在任何列表中使用,因此未在 XML 中返回。

于 2012-12-19T17:06:16.467 回答
2

您总是可以创建一个List Extender来将此信息添加到列表中,但请尽量小心,因为每次调用 GetList 时都会执行此扩展器。

不会让您不必打开列表中的每个关键字,但您将在服务器端进行(例如使用 Core Service/NetTcp),这可能比使用 Anguilla 打开每个关键字更容易和更快。

于 2012-12-19T18:14:55.067 回答
0

在这种情况下,我只需要一个关键字,所以我只需从 CMS 中获取它。在安圭拉获取对象有点奇怪,代码如下:

  1. 在您的主要代码区域:

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

    值得注意的是我如何将关键字存储在项目的属性中,因此我可以在onselectedKyLoaded函数中获取它

  2. 加载项目后调用的函数

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

我解决了这个问题,感谢这里的答案: https ://stackoverflow.com/a/12805939/1221032 - Cheers Nuno :)

于 2012-12-21T15:50:20.387 回答