How do you display an array of data in a template? I have some code that works but it seems extreme, is this really what I need to get it to work?
Controller code
function UKCities()
{
$_list = array('Aberdeen
', 'Armagh
', 'Bangor
', 'Bath
', 'Belfast');
$list = new DataObjectSet();
foreach($_list as $key => $data) {
$data = array('City' => $data);
$list->push(new ArrayData($data));
}
return $list;
}
Template code
<% control UKCities %>
<option>$City</option>
<% end_control %>