Page_List pagination won't work.

Permalink 1 user found helpful
Hi all,

I've been manually using page_list with the code below in my template but I can't seem to make pagination work. I've added a block the visual way in the FRONT-END just to check if I missed something but it work that way. Can anyone tell me if they have that simular problem? Is it a bug?
<?php
               $bt = BlockType::getByHandle('page_list');
               $bt->controller->num = 5; // pages to display
               $bt->controller->orderBy = 'display_asc'; //display_asc, display_desc, chrono_asc, alpha_asc, alpha_desc 
               $bt->controller->cParentID = $c->getCollectionID(); // cID of the page that's above the pages you'd like to list
               $bt->controller->cThis = 1; 
               $bt->controller->paginate = 1; // 0:false / 1:True ( add pagination if more then NUM value )
                $bt->controller->displayAliases = 1; // 0:false / 1:True
               // $bt->controller->ctID = 14; // display only from this page_type ID 
               $bt->controller->rss = 0;
               $bt->controller->truncateSummaries = 0; // 0:false / 1:True
               $bt->controller->truncateChars = 0;
               $bt->controller->displayFeaturedOnly = 0; // 0:false / 1:True = Display is_featured only
               $bt->render('view');
         ?>


I don't understand, I added all controllers and there proper values and pagination dont appear when manually inserting the code.

Thank you

olacom
 
andrew replied on at Permalink Reply
andrew
Our fault. It looks like you're doing everything right, but our page list block is pretty old school, and it unfortunately ignores some of the parameters when you set them this way.

However, I can offer you a possibly better solution: just use the PageList class directly. For example, this code should do what you want, and give you a bit more control (although you'll probably have to tweak it somewhat):

Loader::model('page_list');
$pl = new PageList();
$pl->filterByParentID($c->getCollectionParentID());
$pl->setItemsPerPage(5);
$pages = $pl->getPage();
foreach($pages as $p) { ?>
   <a href="<?=Loader::helper('navigation')->getLinkToCollection($p)?>"><?=$p->getCollectionName()?></a><br/>
<? } ?>
<? $pl->displayPaging()?>
BigBobbyD replied on at Permalink Reply
BigBobbyD
Nevermind this comment!
snebold replied on at Permalink Reply
snebold
This is just what I needed! Thanks!
BigBobbyD replied on at Permalink Reply
BigBobbyD
This was very helpful, but I'm a little stumped trying to change the view of the pagination? What's the best approach?

I posted to this thread already on the topic:http://www.concrete5.org/community/forums/customizing_c5/page_list_...

Sorry to post twice, but there's a relationship between these two threads!

Thank you,
-BBD