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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

[SOLVED] How to get an array of pages ID?

Go to End

3 Posts   1582 Views

Digital Punk

Community Member, 51 Posts

15 January 2010 at 5:26am

Edited: 15/01/2010 1:54pm

Hi there

I'm trying to get automatically an array of pages id (in ex. 29,38):

function GetCategoryNews() {
	  $holderid = DataObject::get("NewsHolder","ParentID = $this->ID");
	  $doSet = DataObject::get(
		$callerClass = "NewsPage",
		$filter = "`SiteTree`.ParentID IN (29,38)",
		$sort = "Date DESC",
		$join = "",
		$limit = ""
	  return $doSet ? $doSet : false;

Maybe someone has an example how to get an array of pages ID or can help with this?

Best regards


Forum Moderator, 5523 Posts

15 January 2010 at 12:18pm

Sorry not sure I completely understand you here. The code you provided would get all the newspages which have the parents IDs of 29 or 38 that should work fine.

However your title suggests you want an array of all the Page ID's. For that you can use the map() method on any dataobjectset to return an array from a dataobjectset.

Digital Punk

Community Member, 51 Posts

15 January 2010 at 1:53pm

No worries, I found solution - just made "holderid" as array:

$filter = "`SiteTree`.ParentID IN ($holderid)"

Anyway, thanks for the response!