Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Creating a simple filter help

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

Page: 1
Go to End
Author Topic: 241 Views
  • nicknick
    Avatar
    Community Member
    15 Posts

    Creating a simple filter help Link to this post

    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

    NewbikeHoldertop

    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
    Nick

    241 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.