Concrete 5 Pagination (Page List Blogs)

Is it possible to have some sort of pagination within the URL in Concrete 5. I see many CMS’s such as WordPress and Drupal etc that have such a feature.

At the moment my blogs are the following:

Read More

/blog?ccm_paging_p_b348=2

and the way I want it to be is:

/blog/page/1 … /blog/page/2 etc (or something similar)

Any tips or advice would be appreciated

Related posts

Leave a Reply

1 comment

  1. Your only choice is to create a custom page type for your blog page and then a custom controller for that which handles the pagination.

    Please see this page:
    http://www.concrete5.org/documentation/developers/pages/mvc-approach

    And particularly the “Page Types” section under “Controllers”. It explains how to create your page type controllers. For them, you can create similar functions that you would for normal single pages, so you can paginate the results there according to the parameters you get from the URL.

    This example is for 5.6 and earlier:

    <?php
    class BlogPageTypeController extends Controller {
    
      public function view($page=1) {
        $pageIndex = intval($page)-1;
        if ($pageIndex < 0) {
          $pageIndex = 0;
        }
    
        $pageList = new PageList();
        $pageList->setItemsPerPage(25);
        $this->set('pages', $pageList->getPage($pageIndex));
      }
    
    }
    

    And then you would use the $pages variable in your view to go through the pages:

    <?php foreach($pages as $page) : ?>
      <h2><?php echo $page->getCollectionName()</h2>
    <?php endforeach; ?>