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.

Customising the CMS /

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

get_by_stage HELP


Go to End


3 Posts   1311 Views

Avatar
cachobong

Community Member, 9 Posts

14 June 2013 at 11:39pm

i got some records using the below code.

$liveRecords = Versioned::get_by_stage('MyRecord', 'Live');

assuming that i don't know the IDs for the records, how do i scan through the records to check their titles to get the one that i want then return this record for it to act like a "get_one_by_stage"

Please help!

Thanks

Avatar
(deleted)

Community Member, 473 Posts

14 June 2013 at 11:46pm

Assuming you're running 3.0, you can just use:

return Versioned::get_by_stage('MyRecord', 'Live')->filter('Title', 'MyTitle')->First();

Avatar
cachobong

Community Member, 9 Posts

15 June 2013 at 12:43am

I'm on 2.4. Is there any way it could be like that in 2.4? I cannot upgrade the version since i'm not the site owner.