5

I need to find components on CM side that satisfy the following conditions:

  • From target publication
  • Based on a target schema
  • Tagged with target keyword

This should be done using tom.net

Currently I have:

  1. Keyword GetListUsingItems to get all items and then parse returned items to find ones matching other criteria
  2. GetListItems on Content folder with schema filter and then parse returned items to find ones matching target keyword

Is it possible to do this with a single query? If not, what would be, performance wise, most optimal way to search for these components?

2 Answers 2

7

It's gonna be something like this:

var filter = new ClassifiedItemsFilter();
filter.ItemTypes = new[] { ItemType.Component };
filter.BasedOnSchemas = new[] { schema };
var components = keyword.GetClassifiedItems(filter);

In TOM.NET you have no control over queries, all the actions are executed just in time, but this code should go to database only once (provided you already have your keyword and schema). It will display you only items from "keyword" publication, I'm not sure, however, if shared components will be shown.

1
  • Tnx @Andrey, this was exactly what I needed. Jun 4, 2015 at 11:58
0

Not clear from the question what do you really want to do with this ultimately; why you really need to code for it.If the requirement is simple that you need to see a list of all components from a specific publication which is based on a particular schema and tagged with a keyword, this can be done out-of-the-box from the SDL Tridion CME itself using the Advanced search feature. Below snapshot shows this: enter image description here

This will work if your parameters (Schema, Keywords and Publication) are fixed (or a small list) - In this case you can save the search as Virtual Folder and can further use it just like a Folder (even through code).

If your requirement is where the parameters (Schema, Keyword) are coming as input dynamically based on some criteria, then you may choose the above code mentioned by Andrey

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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