Skip navigation.
Home

Mixed Object Types in ContentIterWriter

Josh and I were congratulating ourselves on the relative goodness of ContentIterWriter (aka ContentObject), and it's been bouncing around my brain a while.

There was a recent situation where I thought I'd try to put multimedia objects into CIW, and had a hard time. The job to do this never really happened, so figuring it out didn't happen either. I was thinking of creating a hierarchy of tables, where there's a general table for all objects, and a table for each specific type. (That was a bad idea.) Today I think the right way to do it isn't to create a super-type that can hold all types of media, but to create an object that takes CIW objects as input, and sorts them based on a specified field name for each object.

The only constraint is that the CIWs are pre-sorted.

On a call to ->next(), the logic within the aggregator object would look at the sort codes, and pop one of the values.

The display logic can be unrolled into a big switch-like statement. (The templating system doesn't allow for that, but maybe it should.)

The only problem is that you can't select a range of results, like in a regular query. The simplest solution to this is to cache the results, and then read from the cached results.