Jump to content

How to add an addtional count per 4 items


danjapro

Recommended Posts

I would like to add another count that after every 4 items, it loops and create  a added piece of script, by adding <ul><li> tags after every 4 items.

 

I want to addthis piece of code, every fours items after it close </div>

 

            <ul>				
               <li>
                <div class="box">
             <!--All fields and information here-->
                </div>
               <div class="h2"></div>
                <div class="box">
             <!--All fields and information here-->
                </div>
               <div class="h2"></div>
                <div class="box">
             <!--All fields and information here-->
                </div>
               <div class="h2"></div>
                <div class="box">
             <!--All fields and information here-->
                </div>
               <div class="h2"></div>
                   </li>
              </ul>

 

I currently have this piece of code, which builds a list per every <div class="box">, then closes the item </div> and start another one as same.

SEE current CODE.


<?php
    $dealList = $this->dealList;
    if(count($dealList)==0) echo '<h3>'.JText::_('NO_DEAL_MESSAGE').'</h3>';
$count = 1; 
foreach ( $dealList as $row): 
	$link = 'index.php?xxx=' . $row->id;
	if(!Helper::is_urlEncoded($row->pic_dir))
	 {
	 	$imageUrl = $row->pic_dir;
	 }
	 else
	 {
		$imageUrlArr= unserialize(urldecode($row->pic_dir));
		$imageUrl = str_replace("\\","/",$imageUrlArr[0]);
	 }
?>

<div class="box">
information fields here 
</div>


  <?php if ($count%2==1){?>
     <div class="h2"></div>
    <?php }
    else if($count%2==0){?>
    <div class="h3"></div>
   <?php  }$count++ ; endforeach;?>

 

How do I added the Additonal count for efter four items <div class=box"> it places and start over with

<ul>
  <li>
     <div class="box">
      information fields 
     </div>
</li>
</ul>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.