Pagelist show "no pages" if no pages available

Permalink
Hi all,

I am betting this has come up before but I can't find it anywhere on the site... I apologise if it has come up.

I was wondering how to make a Pagelist template that shows a message like "no pages available" if there are no pages to show. Currently it just stays blank when no pages are there to be highlighted.

Any help would be greatly appreciated.

Richard

 
ronyDdeveloper replied on at Permalink Best Answer Reply
ronyDdeveloper
You can copy your page list block into the root blocks folder and edit the view.php or create a custom template for page list. Then edit the view.php

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$rssUrl = $showRss ? $controller->getRssUrl($b) : '';
$th = Loader::helper('text');
//$ih = Loader::helper('image'); //<--uncomment this line if displaying image attributes (see below)
//Note that $nh (navigation helper) is already loaded for us by the controller (for legacy reasons)
?>
<div class="ccm-page-list">
<?php /* +++Added extra */
      if(count($pages) > 0)
      {
?>
   <?php  foreach ($pages as $page):
      // Prepare data for each page being listed...
      $title = $th->entities($page->getCollectionName());


Note: /* +++Added extra */ means this piece of code added additionally into the page list.

Rony
mobius2000 replied on at Permalink Reply
Thank you, this was hugely helpful and apologies for the delay in marking it as best answer