使用特定值和模式检索Tridion 2009组件列表,而不使用搜索

时间:2012-12-05 16:26:28

标签: tridion tridion2009

我想创建一个驻留在CMS服务器上的.NET页面,该页面显示基于特定架构(tcm:3-3-8)和特定出版物(tcm:0-3-1)的所有组件)包括BluePrinted和Localized项目,但前提是该模式中的字段“URL”的值为“http://www.google.com”。

这是否可行,而不使用搜索服务,因为这是相当缓慢和不可靠的?

3 个答案:

答案 0 :(得分:2)

由于未对搜索集合编制索引,您的搜索可能会很慢。

您应该定期为搜索集合建立索引,以获得更好,更快的结果。

答案 1 :(得分:1)

这是一项昂贵的操作,因为打开每个组件以检查字段值的成本,但肯定可行。

  1. 获取架构对象
  2. 获取使用此架构的组件列表(使用ItemType =组件上的过滤器的架构上的WhereUsed)
  3. 打开每个组件并检查字段的值,如果匹配则添加到List<Component>
  4. 显示列表(可能使用ASP.NET GridView)

答案 2 :(得分:0)

我没有机会测试它,但这样的事情

    Common common = new Common();
    TDSE tdse = new TDSE();
    ListRowFilter ComponentFilter = tdse.CreateListRowFilter();



    Schema schema = (Schema)common.getObject("tcm:126-238630-8", ItemType.ItemTypeSchema);
    ComponentFilter.SetCondition("ItemType", ItemType.ItemTypeComponent);
    ComponentFilter.SetCondition("Recursive", true);

    XDocument doc = common.ReadXML(schema.Info.GetListUsingItems(ListColumnFilter.XMLListID, ComponentFilter));
    List<Component> MatchedComponents = new List<Component>();

    XmlNamespaceManager NS = new XmlNamespaceManager(new NameTable());
    NS.AddNamespace("tcm", "http://www.tridion.com/ContentManager/5.0");
    NS.AddNamespace("Content", "uuid:4432F3C3-9F3E-45E4-AE31-408C5C46E2BF");
    foreach (XElement component in doc.XPathSelectElements("/tcm:ListUsingItems/tcm:Item", NS))
    {
        Component comp = common.getComponent(component.Attribute("ID").Value);

        XDocument compDoc = common.ReadXML(comp.GetXML(XMLReadFilter.XMLReadData));
        foreach (XElement compNode in compDoc.XPathSelectElements("/tcm:Component/tcm:Data/tcm:Content/Content:Content/Content:feederUrl", NS))
        {
            MatchedComponents.Add(comp);
        }
    }