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.
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/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.