How to make page list ignore the latest article

Permalink
Hi,

I'm looking for a way to make the first item of my page list to appear differently.
This is easy using the built-in $isFirst variable.
However, it targets the first element of each page whereas I would like to target the first element globally.

Alternatively (actually I would prefer this method), I would like my page_list to display every page except the newest. Again, I would like to apply this condition globally and not on a per-page basis.

I am attaching my code below, minus the pagination part, which is the default one.

<?php  
   defined('C5_EXECUTE') or die("Access Denied.");
   $textHelper = Loader::helper("text");
   $imgHelper = Loader::Helper('image');
   // now that we're in the specialized content file for this block type, 
   // we'll include this block type's class, and pass the block to it, and get
   // the content
   $isFirst = true;
   if (count($cArray) > 0) { ?>
   <?php  
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i]; 
      $target = $cobj->getAttribute('nav_target');
      $title = $cobj->getCollectionName();
      $date = $cobj->getCollectionDatePublic('M j, Y');

VPenkov
 
VPenkov replied on at Permalink Reply
VPenkov
In /concrete/core/helpers/pagination.php there is a function getPreviousURL().
If I find a way to use it, I can check if it returns something. If yes, $isFirst = true, otherwise set it to false.

Ideas, anyone?
VPenkov replied on at Permalink Best Answer Reply
VPenkov
Ok, I dropped $isFirst completely and found out a very simple solution.

After I count the results which pagelist returns, I get the latest child page's id like so:

if (count($cArray) > 0) { 
   $getLatest = Page::getByID(1)->getCollectionChildrenArray(1);
   $latestId = end($getLatest);


After that, inside the for cycle, I just skip it:
if ($childId == $latestId) {
         continue;
      }



So in the end my code looks like this:
<?php  
   defined('C5_EXECUTE') or die("Access Denied.");
   $textHelper = Loader::helper("text");
   $imgHelper = Loader::Helper('image');
   // now that we're in the specialized content file for this block type, 
   // we'll include this block type's class, and pass the block to it, and get
   // the content
   if (count($cArray) > 0) { 
   $getLatest = Page::getByID(1)->getCollectionChildrenArray(1);
   $latestId = end($getLatest);
   ?>
   <?php  
   for ($i = 0; $i < count($cArray); $i++ ) {
      $cobj = $cArray[$i]; 
      $target = $cobj->getAttribute('nav_target');


Finally, I just created another block to display my latest article and I'm good to go.

This website stores cookies on your computer. These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media. To find out more about the cookies we use, see our Privacy Policy.