简体   繁体   English

Tridion DynamicContent.Query按组件模板搜索

[英]Tridion DynamicContent.Query Searching By Component Template

I'm trying to render all component presentations from the broker database with a certain component template. 我正在尝试使用特定组件模板从代理数据库中呈现所有组件演示文稿。 Here's the query code so far: 这是目前为止的查询代码:

using Tridion.ContentDelivery.DynamicContent;
using Tridion.ContentDelivery.DynamicContent.Query;

ItemTemplateCriteria CTCriteria = new ItemTemplateCriteria(1111);
PublicationCriteria pubCriteria = new PublicationCriteria(10);
AndCriteria finalCriteria = new AndCriteria(pubCriteria, CTCriteria);

Response.Write("<h1>START</h1>");

Query q = new Query();
q.Criteria = finalCriteria;

string[] result = q.ExecuteQuery();

if (result != null && result.Length > 0)
{
    foreach (string r in result)
    {
        Response.Write("<h1>" + r + "</h1>");
    }
}
else {
    Response.Write("Result is null or 0-length.");
}
Response.Write("<h1>END</h1>");

I keep getting null results. 我一直得到null结果。 I do have dynamic content publishing setup in cd_storage_conf.xml and a few component presentations published in the Broker database. 我在cd_storage_conf.xml有动态内容发布设置,在Broker数据库中发布了一些组件演示。

My understanding from this document is that, I should be able to retrieve related component URIs using this approach. 我从该文档中了解到,我应该能够使用这种方法检索相关的组件URI。

My Questions : 我的问题

  1. Is my understanding of the capabilities of the Query class correct? 我对Query类功能的理解是否正确?
  2. Did I miss anything, config and code-wise? 我错过了什么,配置和代码吗?
  3. Is there any other way of retrieving broker content by component template? 是否有其他方法可以按组件模板检索代理内容?

EDIT : 编辑

Additional info: Regarding ItemTemplateCriteria , I only assumed that this is used for searching records by Component Template. 附加信息:关于ItemTemplateCriteria ,我只假设它用于按组件模板搜索记录。 I assumed because there is another criteria class called PageTemplateCriteria . 我假设是因为还有另一个名为PageTemplateCriteria标准类。 Please correct me if this assumption is invalid. 如果此假设无效,请更正我。

EDIT : 编辑

Additional info: I've inspected the COMPONENTS , SCHEMA and TEMPLATES tables in the broker database but didn't find the published components there. 附加信息:我已经检查了代理数据库中的COMPONENTSSCHEMATEMPLATES表,但没有在那里找到已发布的组件。 By default rule in the cd_storage_conf.xml , published content must go to the broker. 默认情况下,在cd_storage_conf.xml ,发布的内容必须转到代理。 For reference, here's my config: 作为参考,这是我的配置:

<Publication Id="57" defaultStorageId="brokerdb" cached="false">
    <Item typeMapping="ComponentPresentation" storageId="brokerdb" cached="false" />
    <Item typeMapping="BinaryMeta" cached="true" storageId="brokerdb"/>
    <Item typeMapping="BinaryVariant" cached="true" storageId="brokerdb"/>
    <Item typeMapping="Binary" storageId="defaultFile" cached="true"/> 
    <Item typeMapping="ComponentMeta" cached="true" storageId="brokerdb"/>
    <Item typeMapping="ComponentPresentationMeta" cached="true" storageId="brokerdb"/>
    <Item typeMapping="ItemMeta" cached="true" storageId="brokerdb"/>
    <Item typeMapping="LinkInfo" cached="true" storageId="defaultDataFile"/>
    <Item typeMapping="DynamicLinkInfo" cached="true" storageId="defaultDataFile"/>
    <Item typeMapping="Page" cached="true" storageId="defaultFile"/> 
    <Item typeMapping="PageMeta" cached="true" storageId="defaultDataFile"/>
    <Item typeMapping="Reference" storageId="brokerdb"/>
    <Item typeMapping="Schema" storageId="brokerdb"/>
</Publication>

Double check your cd_storage_conf.xml and database to check the items are stored there. 仔细检查cd_storage_conf.xml和数据库以检查项目是否存储在那里。 If your data is going to the file system it will not be query-able. 如果您的数据进入文件系统,则无法查询。

Specifically I think the ComponentPresentationMeta must be going to the DB for this scenario to work. 具体来说,我认为ComponentPresentationMeta必须转到数据库才能使用此方案。

Also check your cd_licenses.xml file, if it is expired, if it is (even if the cd_storage_conf.xml is correct), the items will end up on the file system. 还要检查你的cd_licenses.xml文件,如果它已经过期,如果是的话(即使cd_storage_conf.xml是正确的),这些项目最终会在文件系统上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM