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.

Data Model Questions /

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


Reply


3 Posts   1186 Views

Avatar
Digital-Punk.co.uk

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
Mindaugas

Avatar
Willr

Forum Moderator, 5513 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.

Avatar
Digital-Punk.co.uk

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!