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.

Data Model Questions /

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

[solved] ss 2.4.5 CaseStudy feed on home page only takes from first holder in site tree


Go to End


4 Posts   1299 Views

Avatar
neilos

Community Member, 19 Posts

4 June 2013 at 2:02am

Hi,

I'm sure this is a simple solution, but I have spent a long time on this and can't figure it out.

I have an old version (2.4.5) site that has a case studies section that feeds 2 most recent articles to home page.
At least it should, but it only feeds the case studies that are children of the first CasestudyHolder in the site tree.

How do I get it to list the two most recent CasestudyPage on the home page regardless of which CasestudyHolder they belong to?

	function CaseStudy($num=2) {
  	$casestudy = DataObject::get_one("CasestudyHolder");
  	return ($casestudy) ? DataObject::get("CasestudyPage", "ParentID = $casestudy->ID", "Date DESC", "", $num) : false;
	}

Regards,
neilos

Avatar
neilos

Community Member, 19 Posts

12 June 2013 at 10:37pm

Has anyone had this problem before?

Avatar
Devlin

Community Member, 344 Posts

12 June 2013 at 11:35pm

function CaseStudy($num=2) {
	return DataObject::get("CasestudyPage", null, "Date DESC", "", $num);
}

Avatar
neilos

Community Member, 19 Posts

13 June 2013 at 12:54am

Thanks Devlin, that's the ticket!