4

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>
Ianthe the Duke of Nukem
  • 1,721
  • 2
  • 20
  • 37
  • 2
    Guys, this turns out to be a configuration issue. My deployer's `cd_storage_conf.xml` was using file system for everything **except** component presentations. After configuring and republishing the components, I was able to retrieve the components! – Ianthe the Duke of Nukem Nov 28 '12 at 08:10
  • Nice question, could we interest you in committing to the [Area 51 Tridion specific proposal](http://area51.stackexchange.com/proposals/38335/tridion?referrer=gPujQMxthNCNn9xqeeO2NA2). Sign up with the same SO account if you have a moment. – Bart Koopman Nov 29 '12 at 09:35
  • Sure Bart! I'll check it out. – Ianthe the Duke of Nukem Nov 29 '12 at 09:55

1 Answers1

5

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.

Chris Summers
  • 10,153
  • 1
  • 21
  • 46
  • 1
    I did, Chris. The `cd_storage_conf.xml` for the deployer was wrong. The config in my question came from the website's config. This is why the component info was not published to the broker db. After I synchronized both configuration, I was able to publish to the database and retrieve using the DynamicContent.Query API. – Ianthe the Duke of Nukem Nov 28 '12 at 13:54