keldek Posted December 20, 2007 Share Posted December 20, 2007 Hello, I'm working on creating a gallery for my site, and have run into a small issue that I cannot seem to resolve. First, my code: <?php if ($this->displayimagecategories == 1) { echo '<table border="0">'; echo '<tr>'; foreach ( $this->categories as $category ) { echo '<td width="20%" align="center"><a href="'.$category->link.'">'.JHTML::_( 'image.site', $category->linkthumbnailpath, '', '', '', $category->title, 'style="border:0"' ).'</a>'; echo '<br><a href="'.$category->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$category->title.'</a> '; echo '<br><span class="small">('.$category->numlinks.')</span></td>'; echo '</tr>'; } echo '</table>'; } else { ?> This works perfect for what I need it to do, except that I need to add some form of if statement that will count how many <td> tags there are, and if the <td> tag count = 5, it'll close the open <tr> and create a new <tr>. If anyone could provide some insight on this issue, I would greatly appreciate the help. Thanks in advance for your help and time. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 20, 2007 Share Posted December 20, 2007 something like this should work.. <?php if ($this->displayimagecategories == 1) { echo '<table border="0">'; echo '<tr>'; $intCounter = 0; foreach ( $this->categories as $category ) { $intCounter++; echo '<td width="20%" align="center"><a href="'.$category->link.'">'.JHTML::_( 'image.site', $category->linkthumbnailpath, '', '', '', $category->title, 'style="border:0"' ).'</a>'; echo '<br><a href="'.$category->link.'" class="category'.$this->params->get( 'pageclass_sfx' ).'">'.$category->title.'</a> '; echo '<br><span class="small">('.$category->numlinks.')</span></td>'; if (($intCounter%5)==0) {echo "</tr><tr>";} } echo '</tr></table>'; } else { ?> Quote Link to comment Share on other sites More sharing options...
keldek Posted December 20, 2007 Author Share Posted December 20, 2007 Perfect! Thanks a ton Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.