Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Simple query

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 727 Views
  • neogin
    Avatar
    Community Member
    13 Posts

    Simple query Link to this post

    Hi guys,

    I'm very new to silverstripe and I'm still struggling with the php etc...So I've been trying to reverse-engineer quite everything to make a website for my lab ( www.cpmoh.cnrs.fr/SLAM ). So I'm sorry if this is basic stuff.

    My question is the following : I've got a particular type of page, StaffPage, with a field in it $position, I'd like to display only the pages with a specific $position ( such as "ph.student" ).

    So I could use a <control PhdPosition> $Name <end control> that would only display the StaffPage of people making a Ph.D.

    I'm pretty sure it is possible but as I said I've been reverse-engineering everything and I don't know how to properly do that.

    Thanks for your help
    Best regards

  • UncleCheese
    Avatar
    4085 Posts

    Re: Simple query Link to this post

    public function StaffPagesByPosition($pos)
    {
    return DataObject::get("StaffPage","Position = '$pos'");
    }

    <% control StaffPagesByPosition(Phd) %>
    $Title
    <% end_control %>

  • neogin
    Avatar
    Community Member
    13 Posts

    Re: Simple query Link to this post

    Works perfectly and now I finaly understand how to query what I want

    Thanks

  • neogin
    Avatar
    Community Member
    13 Posts

    Re: Simple query Link to this post

    you can see the result in : http://www.cpmoh.cnrs.fr/SLAM/people.html

    727 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.