Jump to content

[SOLVED] An odd situation/problem


keldek

Recommended Posts

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.

Link to comment
Share on other sites

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
{
?>

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.