Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

I am using TOM API. I have to fetch all multimedia components on basis of publication ID. I am using List row filter as below.

      Publication pub = tdse.GetPublication(publicationUri);
                    ListRowFilter rowFilter = tdse.CreateListRowFilter();
                    rowFilter.SetCondition("ItemType", ItemType.ItemTypeMultimediaType);
                    rowFilter.SetCondition("Recursive", true);
 componentsList.LoadXml(pub.GetListItems(ListColumnFilter.XMLListDefault, rowFilter));

Is there any way to filter multimedia components using ListRowFilter class?

share|improve this question

3 Answers 3

The ItemType.ItemTypeMultimediaType enum if for getting Multimedia Types out of Tridion and not Multimedia Components. The ItemType.ItemTypeComponent grabs all components, normal and multimedia. You could always do your filtering programatically, however this could be very inefficient if you have thousands of components you need to sort through. Something that you can try though to ensure you are just pulling back the data you need is playing with the "BasedOnSchema" condition and passing it the schemas (or ID's of the schemas) of the multimedia components that you want to return. If you already know the Multimedia Schemas of the components you want to search for, you could pass into this Condition:

  • One Schema object
  • An array of Schema objects
  • A TCM URI
  • An array of TCM URIs
  • A collection of Schema object (a TDS.Schemas object)

Using the "BasedOnSchema":

ListRowFilter rowFilter = tdse.CreateListRowFilter();
rowFilter.SetCondition("BasedOnSchema", yourSchemaIds);

Note that when you use the "BasedOnSchema" condition, you don't have to specify the "ItemType" condition as its already assumed that its of type "ItemType.ItemTypeComponent".

If you want to be a bit more dynamic (that is, you don't know the multimedia schemas off hand and you just want to pull everything out that is using one), you could do two passes of GetListItems. The first pass you could grab all of the multimedia schemas, and then use that data to build the correct arguments for "BasedOnSchema" for your second pass of GetListItems to get all of the components using those schemas.

An example of getting all of the multimeida schemas out, you can do something like:

ListRowFilter schemaRowFilter = tdse.CreateListRowFilter();
schemaRowFilter.SetCondition("SchemaPurpose", EnumSchemaPurposes.PurposeMultimedia);

Note that you don't have to put the "ItemType" condition in the above, when using "SchemaPurpose" it will automatically use the type ItemType.ItemTypeSchema.

Hope that helps!

share|improve this answer

The item type for a multimedia component is Component, not MultimediaType. Otherwise, your code looks OK. You'll get all the components, though, so you can either test each component to see if it is multimedia, or add a schema filter.

share|improve this answer

You have not mentioned the Tridion version, however, I have faced one issue with SDL Tridion 2009 while using TOM API and the BasedOnSchema filter for getting the Components. I observed earlier that the BasedOnSchema filter and the Recursive filter do not work together (It tends to bring all the items available at the root folder and not through the entire hierarchy). May be you can verify and update the group if it works for you.

I usually try to retrieve the Multimedia Components from a list of components by checking for Component.Multimedia attribute. This attribute will be Not Null for all multimedia components and Null for rest of them.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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