I'm writing my very own Joomla component (MVC), its based heavily around the newsflash module, because I wish to display the most recent 5 content products inside a sliding tabbed interface, all of the effort is performed, however i am getting real difficult getting content from the for loop.

This is actually the code I've to date default.php

<ul id="handles" class="tabs">
    <?php for ($i = 0, $n = count($list); $i < $n; $i ++) :
     endfor; ?>                
<li class="end"></li>


function getTabs(&$item)
    global $mainframe;

    $item->created     = $item->created;

    list($year, $month, $day) = split("-", $item->created);
    $tabdate = date('d\/m\/y', mktime(0, 0, 0, $month, $day, $year));

    require(JModuleHelper::getLayoutPath('mod_sankeslide', '_tab'));


<li><a href="#tab"><span><?php echo 'Shout ' . $tabdate; ?></span><b></b></a></li>

The very first item will need different value along with a class item put into the a: item, so I have to have the ability to identify the first item and make a move throughout that loop.

I attempted to make use of if $i = else statement within the default.php, however it led to a webpage timeout for whatever reason!

Any ideas?

You stated, you attempted if $i = 0, the comparison operator in PHP is ==, together with your for those who have a never-ending loop, because in every iteration you assign to $i, also it never reaches $n, you want to do within your loop:

if ($i == 0){
  // First Item here...

  // Other Items...


I believe @Content management systems is correct.

You could also wish to consider handling the very first item outdoors the loop and letting the loop handle the relaxation from the products. By doing this it's not necessary to result in the check up on each go through the loop.

If you are utilizing a plain for loop, I'd recommend just functioning on the first item after which looping with the relaxation as tvanfosson said. It's slightly faster and potentially simpler to see...


for ($i = 1; $i < count($list); $i++) {

I am inclined to use foreach over for to loop over arrays, by which situation, I'd make use of a "firstDone" var, like so:

$bFirstTime = true;
foreach($list as $item) {
    if ($bFirstTime) {
        $bFirstTime = false;
    } else {