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

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Simple query


Go to End


4 Posts   1426 Views

Avatar
neogin

Community Member, 13 Posts

23 November 2009 at 7:42am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

23 November 2009 at 8:07am

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

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

Avatar
neogin

Community Member, 13 Posts

23 November 2009 at 11:19pm

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

Thanks

Avatar
neogin

Community Member, 13 Posts

23 November 2009 at 11:20pm

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