Page list Newest items different layout

Permalink
For a news overview page I like to display the latest news different then the rest.

What I'm doing doesn't work for the second part. It just shows the same item over and over depending on how many more pages there are.

<ul id="newsoverview">
<?php 
   for ($i = 0; $i < count($cArray); $i++ ) {
   $cobj = $cArray[$i]; 
   $title = $cobj->getCollectionName();
   $ih = Loader::helper('image');
   $img = $cobj->getAttribute('newsimg');
   $thumb = $ih->getThumbnail($img, 230, 153, false);
   $thumb2 = $ih->getThumbnail($img, 87, 57, false);
   $date = $cobj->getCollectionDatePublic('j M Y'); 
   if ($i < 3) {
    ?>    
    <li class="newsitem"><a title="<?php  echo $title ?>" href="<?php echo $nh->getLinkToCollection($cobj) ?>" target="<?php  echo $target ?>">
    <span class="date"><?php  echo $date ?></span>           
    <h2><?php  echo $title ?></h2>

Dutchwave
 
drbiskit replied on at Permalink Reply 1 Attachment
drbiskit
Here you go. I think this should do what you want - I've attached a .txt file too.

This is very basic just to illustrate the logic. I've just thrown it together so you'll need to add in all of your other markup etc.

Hope it helps!

<?php 
defined('C5_EXECUTE') or die(_("Access Denied."));
$th = Loader::helper("text"); 
$pg = Page::getCurrentPage();
$pgID = $pg->getCollectionID();
$n = 0;
?>
<ul>
<?php  foreach ($pages as $page):
   // Prepare data for each page being listed...
   $title = $th->entities($page->getCollectionName());
   $url = $nh->getLinkToCollection($page);
   $n++;
    ?>
     <?php if ($n == 1) { ?>
Dutchwave replied on at Permalink Reply
Dutchwave
It helped for sure, thanks! Actually more in a different way to approach the issue.
I was trying to break it up with another ul, but that won't work with if else (or does it?)
So gave the second li a different class instead, sort of like your example and added the else statement.

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$rssUrl = $showRss ? $controller->getRssUrl($b) : '';
$th = Loader::helper('text');
$ih = Loader::helper('image');
?>
<ul id="newsoverview">
<?php 
   for ($i = 0; $i < count($cArray); $i++ ) {            
   $cobj = $cArray[$i]; 
   $title = $cobj->getCollectionName();
   $ih = Loader::helper('image');
   $img = $cobj->getAttribute('newsimg');
    $desc = $cobj->getCollectionDescription();
   $thumb = $ih->getThumbnail($img, 230, 153, false);