12 January 2012 at 12:56am
assuming that you create the array() within an Model extending Page / SiteTree I guess I would create a DataObjectSet (http://api.silverstripe.org/2.4/sapphire/model/DataObjectSet.html) and return it to the Template. There you can loop it as a control.
Besides that I think that you should try to get this DataObjectSet directly from DB, without writing it into an array first and than back. Also I would try to get the Set with just one request. Doing DB-Requests (DataObject::get()) within a loop are not ideal for system performance and can be usually replaced by a single one (that's what databases live for ;)).