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.
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
- Previous 10 entries
- 1
- Page 22(current)
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);
}
- Previous 10 entries
- 1
- Page 22(current)