Page List To Display Multiple Sub Pages?

Permalink 1 user found helpful
I'm building a site to display schedules for our local sports team.

So under my SCHEDULES Page. I have a page each for Football, Basketball and Hockey.

Under each of those, I have pages for the daily schedule of games.

I want a page list to display EVERY schedule for all the sports, so I set it to display pages underneath the Schedules page...but it's only showing me the three sub pages. What I want is EVERY page underneath schedules, including subpages.

How can I do that?

leinteractive
 
leinteractive replied on at Permalink Reply
leinteractive
Sorry to bump my own thread...still wondering if there is a way for a Page List to display all sub-pages underneath a given page as opposed to just the first level sub-pages.

Thanks!
leinteractive replied on at Permalink Reply
leinteractive
Is there a way for a PageList to display ALL pages underneath a given page, not just the first level sub-pages?
TheRealSean replied on at Permalink Reply
TheRealSean
I am not to sure but I think you should be able to run the following

Loader::model('page_list');
//then within each listing create a new page list instance
$pageList = new PageList();
$pageList->filterByParentID($cobj->getCollectionID());
$pages = $pageList->get();
//that will grab a collection of all the current pages within that page
//then you should just need to play around with echoing out the bits you need?
//something like 
<div>
//no idea if this would work I can not remember if the $pages is an object or an array? but I think its an array
foreach($pages  as $page){
//display page information
}
</div>
leinteractive replied on at Permalink Reply
leinteractive
Not really sure where I would put that thought?

I'm kinda wondering if I'd be better off making a new template for the auto-nav as opposed to trying the make a square peg fit in a round hole with a page list?
KJLJon replied on at Permalink Reply
KJLJon
I am having the same sort of problem as leinteractive.

I tried your code out but my problem is it doesn't sort it (I guess I could manually sort it using php?), but I just want to check if someone has an easier way.

Here is a description of my website layout.
I have 3 page types:
Page, Subject, Subject_Post

Sitemap [Title (Page Type)]:
Home (Page)
-Blog (Subject)
--2011 (Subject)
---My_First_Blog_Post (Subject_Post)
-Projects (Subject)
--Arts_&_Crafts (Subject)
---Halloween (Subject_Post)
---Christmas_Ornaments (Subject_Post)
--Photography (Subject)
---Crazy_Storm (Subject_Post)
...etc...

So for example, I can get Blog to show either 2011 or to show all the Subject_Post (from every were) but I am looking to only get the page type "Subject_Post" underneath the current "Subject".

IE I am trying to get "Projects" to show "Halloween", "Christmas_Ornaments", and "Crazy_Storm" sorted by "With the Most Recent First" and have a Pagination and only display 10 pages.

I am going to work on finishing the code TheRealSean posted (It's a good start) to have it grab 10 pages of each "Subject" page underneath the current page it's on and sort all of these (n subject pages)*10 pages it grabs by the date and only output 10 of them

Now thinking about it, I am wondering how I can get the Pagination to work properly using this method? Any ideas?

Thank you for all your help :)

Hopefully there is a different way I can get this to work.
TheRealSean replied on at Permalink Reply
TheRealSean
@leinteractive
The autonav block has already done alot of the work to get the sub pages to display, so thats often my route when I want to show multiple sub pages.

I don't have the time to have a go at this for a working demo, but if I can find some time over the weekend Ill see if I can take a stab at it, to get something out putting in the page list that I know works

@KJLJon
You are correct the Pagelist would need sorting, but the concrete5 devs have thought ahead ;-)

There are a few options you can use to sort and filter the results a full list can be found here.
http://www.concrete5.org/documentation/developers/pages/searching-a...

But for your case,
$pageList->sortByPublicDateDescending();
$pageList->get(10);

You could even add in your own filter or sort. An example could be to filter all Pages that of type, then filter by a customAttribtute
KJLJon replied on at Permalink Reply
KJLJon
Thanks :)
KJLJon replied on at Permalink Reply
KJLJon
So here is what I did (in case anyone is wondering).

NOTE: this is a little more advance then some people may want to get into.

I copied the /concrete/blocks/page_list to /blocks/page_list

in /blocks/page_list/controller.php on line 31 look for
if ($this->bID) {
   $q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btPageList where bID = '$bID'";
   $r = $db->query($q);
   if ($r) {
      $row = $r->fetchRow();
   }
} else {
   $row['num'] = $this->num;
   $row['cParentID'] = $this->cParentID;
   $row['cThis'] = $this->cThis;
   $row['orderBy'] = $this->orderBy;
   $row['ctID'] = $this->ctID;
   $row['rss'] = $this->rss;
   $row['displayAliases'] = $this->displayAliases;
}

change it to
if ($this->bID) {
   $q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btPageList where bID = '$bID'";
   $r = $db->query($q);
   if ($r) {
      $row = $r->fetchRow();
   }
   $row['path'] = false;
} else {
   $row['num'] = $this->num;
   $row['cParentID'] = $this->cParentID;
   $row['cThis'] = $this->cThis;
   $row['orderBy'] = $this->orderBy;
   $row['ctID'] = $this->ctID;
   $row['rss'] = $this->rss;
   $row['displayAliases'] = $this->displayAliases;


and then around line 81 look for
if (is_object($c)) {
  $this->cID = $c->getCollectionID();
}

and change it to
if (is_object($c)) {
  $this->cID = $c->getCollectionID();
  if($row['path']) $pl->filterByPath($c->getCollectionPath());   
}


and then you will have to hard-code in the page_list into the page. Here is an example of what I did:
$bt = BlockType::getByHandle('page_list');
$bt->controller->num = 10;
$bt->controller->cParentID = 0;
$bt->controller->cThis = 1;
$bt->controller->orderBy = 'alpha_desc';
$bt->controller->ctID = 10;
$bt->controller->rss = 0;
$bt->controller->displayAliases = 1;
$bt->controller->path = 1;
$bt->render('view');