Question

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. I do have dynamic content publishing setup in cd_storage_conf.xml and a few component presentations published in the Broker database.

My understanding from this document is that, I should be able to retrieve related component URIs using this approach.

My Questions:

  1. Is my understanding of the capabilities of the Query class correct?
  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. I assumed because there is another criteria class called 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. By default rule in the cd_storage_conf.xml, published content must go to the broker. 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>
Was it helpful?

Solution

Double check your cd_storage_conf.xml and database to check the items are stored there. 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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top