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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Multiple DataObject Problem

Go to End

10 Posts   1405 Views


Forum Moderator, 5513 Posts

15 July 2011 at 8:59am

You may want to read up on switch ( you should only need 1 switch statement to do that.


Community Member, 123 Posts

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";

case 'Purple':
$color = "NewsPurplePage";

case 'Magenta':
$color = "NewsMagentaPage";

case 'Blue':
$color = "NewsBluePage";

return DataObject::get($color, "", "StartDate DESC", "", $num);

Go to Top