7
int iPubId = Integer.parseInt(publicationId);
CriteriaFactory criteriaFactory = new CriteriaFactory();
PublicationCriteria pubCriteria = new PublicationCriteria(iPubId);
ItemTypeCriteria IsSchema = new ItemTypeCriteria(ItemTypes.SCHEMA);
Criteria allCriteria = criteriaFactory.And(pubCriteria,IsSchema);
Query myQuery = new Query();
myQuery.setCriteria(allCriteria);
SortParameter sortParameter = new SortParameter(SortParameter.ITEMS_TITLE, 
                                                SortParameter.ASCENDING);
myQuery.addSorting(sortParameter);
String[] itemResults = myQuery.executeQuery();
System.out.println("RERERERESULTS:"+itemResults.length);
  • Hello and welcome the Tridion Stack Exchange. Are you setup to actually publish schemas? You can filter to get certain component presentations based on a given schema, but the schemas aren't available in Content Delivery afaik, unless you put them there. – Alvin Reyes Jun 18 '13 at 19:12
4

I am guessing your issue is related to this:

https://stackoverflow.com/questions/14530742/schematitlecriteria-yield-no-results-in-sdl-tridion-broker-query

I found that the titles of the schema's names are not actually deployed to the broker until at least one DCP based on that Schema has been published.

| improve this answer | |
  • Hmm, I don't read the question this way. It looks like the OP is trying to create a query to get back the list of schema names. The other scenario is about getting DCPs based on a specific schema. Is the full list of schema names possible with the CD API in a single query? – Alvin Reyes Oct 1 '13 at 7:10
3

Try this way:-

Query myQuery = new Query();

Criteria myCriteria = null;
ItemTypeCriteria isSchema = new ItemTypeCriteria(8);
PublicationCriteria pubCriteria = new PublicationCriteria(251);
AndCriteria andCriteria = new AndCriteria(isSchema, pubCriteria);

myCriteria = andCriteria;

myQuery.setCriteria(myCriteria);

SortParameter sortParameter = new SortParameter(SortParameter.ITEMS_SCHEMA_ID, 
                                                SortParameter.ASCENDING);

myQuery.addSorting(sortParameter);
//myQuery.setResultFilter(new LimitFilter(25));

String[] itemResults = myQuery.executeQuery();
System.out.println("RESULTS: " + itemResults.length); 

Note that I haven't tested yet

| improve this answer | |
0

You can, by default, publish pages and (dynamic) component presentations to content delivery along with their metadata (including template metadata now, I believe).

Schemas may be in the Broker database, but doing the following doesn't make sense (I'd expect components or pages):

ItemTypeCriteria IsSchema = new ItemTypeCriteria(ItemTypes.SCHEMA);

You can, however, get all CPs based on a specific schema:

SchemaTitleCriteria criteria = new SchemaTitleCriteria("article");

You could get the list of schemas in delivery by publishing out a configuration (xml) page or store it in a dcp. This might be a use case to use the Core Service in delivery, but I wouldn't recommend it.

You could also configure Tridion.ContentManager.config to actually render schemas but you'd need a custom resolver along with whatever content delivery code you need to get this information. But it'd be easier to use a template building block assembly.

| improve this answer | |
  • Schema Names are published along with DCPs, but not if the components are just embedded on a page – Chris Summers Jun 19 '13 at 2:47
  • Makes sense. In my setup I can see at least two schemas in the schemas table but can't get them back via the API (without first getting the DCPs). – Alvin Reyes Jun 19 '13 at 3:03
  • But I still doubt we can get the list of schemas in a single query. :-) – Alvin Reyes Oct 1 '13 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.