Sounds like this would be similar to the way a gallery would operate. You might look into using an external XML file to hold the information need for the Query.

The template could be generated...