Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

Using multileveled DataObjectSets in a control?


Go to End
Reply


2 Posts   1396 Views

Avatar
patrik

Community Member, 9 Posts

8 July 2009 at 2:32am

Edited: 08/07/2009 2:34am

Hi!

I have a method in my controller which collects data like this:

public function GetData() {
$sqlQuery = new SQLQuery();
$sqlQuery->select("website");
$sqlQuery->from("listsitem");
$sqlQuery->groupby("website");
$result = $sqlQuery->execute();
$data = new DataObjectSet();

foreach($result as $row) {
$data->push(DataObject::get("ListsItem", "website ='".$row['website']."'", "", "", 2));

}
}

Before i did like this.
public function GetData() {
return DataObject::get("ListsItem", "website ='".$row['website']."'", "", "", 2));
}
And that worked fine with just:
<% control GetData %>
...
<% end_control%>

But how do i use the values from the dataset if its a multilevel array? I can't seem to find anything about this in the manual.

I would be very grateful for help with this!

Avatar
patrik

Community Member, 9 Posts

8 July 2009 at 10:48pm

Anyway, i solved it by iterating in the controller, instead of the template

$data = new DataObjectSet();
foreach($result as $row) {
$tmpRes = DataObject::get("ListsItem", "website ='".$row['website']."', "", "", 2);
foreach($tmpRes as $t) {
$data->push($t);
}
}