Obtaining component title from the Tridion broker

247 views Asked by At

This code works to get content from the broker for all components whos name begins with "MC":

    Criteria c1 = new ItemTitleCriteria("MC%",  Criteria.Like);

    //Create query
    Query myQuery = new Query(c1);

    String[] itemURIs = myQuery.ExecuteQuery();
    ComponentPresentationAssembler cpAssembler = new ComponentPresentationAssembler();
    foreach (string componentUri in itemURIs)
    {
        String content = cpAssembler.GetContent(componentUri, componentTemplateUri);
    }

However, I am struggling to find in the api where I can actually access the names (or titles) of each component returned.

1

There are 1 answers

0
Ianthe the Duke of Nukem On

I'm not sure if the broker API has such capabilities to retrieve those attributes. You may probably need to use another library to retrieve information from the CMS.

But to answer your question, one way to get the title if to publish it to the brokerDB as part of the content (cpAssembler.GetContent()). Just make sure that you render Component.Title in the component template. Once it's in the DB, you can parse it.

Sample content:

<model id="modelId" title="componentTitle" />

Note: Tridion has its own StackExchange site now, you may get more interaction there. https://tridion.stackexchange.com/