21309 Posts in 5738 Topics by 2603 members
| Go to End | ||
| Author | Topic: | 829 Views |
-
Re: Multiple DataObject Problem

15 July 2011 at 8:59am
You may want to read up on switch (http://php.net/manual/en/control-structures.switch.php) you should only need 1 switch statement to do that.
-
Re: Multiple DataObject Problem

16 July 2011 at 3:47am
Hi Will,
I took a look at that and rewrote the code the way you said this time adding the break; statement and it works great.
Thanks for all your help. It's great to get something to finally work but even better when you know it's been done right
function NewsList($num=5) {
switch($this->PageColor) {
case 'Gold':
$color = "LstGoldPage";
break;case 'Purple':
$color = "NewsPurplePage";
break;case 'Magenta':
$color = "NewsMagentaPage";
break;case 'Blue':
$color = "NewsBluePage";
}return DataObject::get($color, "", "StartDate DESC", "", $num);
}
| 829 Views | ||
| Go to Top |


