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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Creating a simple filter help

Go to End



Community Member, 15 Posts

28 February 2013 at 12:00pm

Hi all, since last on ive been busy creating my site and i have to say its getting easier but i need a little help again.
im writing pages for motorbike sales and the flow is like this


NewbikeHolder->Make 1
BikePage ->bike1
BikePage ->bike2
BikePage ->bike3
NewbikeHolder->Make 2
BikePage ->bike1
BikePage ->bike2
BikePage ->bike3
NewbikeHolder->Make 3
BikePage ->bike1
BikePage ->bike2
BikePage ->bike3

Hope thats clear as mud lol (its the admin tree view if you like)
anyway when a visitor gets down to BikePage level the get the details and pics for the bike make and model i.e one entry
now on that page ive created a css scroller to scroll image1 of my many-many images (using an if exists loop) this works mint. but i can only filter it by inputting the NewbikeHolder Id in manually, so when a visitor is viewing Make3 Bike 3 he sees scrolling images for Make1 bikes.

anyway here is the code i need to filter and perhaps it will make perfect sense.

public function Otherbikes($num=10) {
    $holder = NewbikeHolder::get();
    return ($holder) ? BikePage::get()->filter(array('ParentID' => '32'))->limit($num) : false;

i need to change the below line to $Up.ID instead of 32 or similar.
BikePage::get()->filter(array('ParentID' => '32'))->limit($num)

so the above code runs in BikePage.php This is the currently at page and i need to call the data for all members of this pages parent id. i.e bike1, bike2, bike3 etc.

I hope ive explained it well enough and im sure its simple if your not working through it by trial and error like me.

Thanks in advance