PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
finbiro
Forum Newbie
Posts: 2 Joined: Fri Oct 03, 2008 5:58 am
Post
by finbiro » Fri Oct 03, 2008 6:13 am
This is how it works now:
New row is created for every item, so the current code loks like this:
Code: Select all
<table>
<?php foreach($list as $item) : ?>
<tr><td>
<div class="banneritem<?php echo $params->get( 'moduleclass_sfx' ) ?>"><?php
echo modBannersHelper::renderBanner($params, $item);
?><div class="clr"></div>
</div>
</tr></td>
<?php endforeach; ?>
</table>
I need to put items in 2 columns.
So:
now is ______ should be
1 __________ 1 2
2 __________3 4
3 __________ 5 6
4 __________ 7 8
Please help ASAP!
Last edited by
finbiro on Fri Oct 03, 2008 11:19 am, edited 1 time in total.
Kadanis
Forum Contributor
Posts: 180 Joined: Tue Jun 20, 2006 8:55 am
Location: Dorset, UK
Contact:
Post
by Kadanis » Fri Oct 03, 2008 9:10 am
How about using the index of the array rather than the foreach loop, and increment by 2 each time. Not sure what template engine you are using, but this should work as long as $item is equal to $list[$x]
Code: Select all
<table>
<?php
for ($x = 1; $x <= $list; $x +=2):
$item = $list[$x];
$item2 = $list[$x+1];
?>
<tr>
<td>
<div class="banneritem<?php echo $params->get( 'moduleclass_sfx' ) ?>">
<?php echo modBannersHelper::renderBanner($params, $item);?>
<div class="clr"></div>
</div>
</td>
<td>
<div class="banneritem<?php echo $params->get( 'moduleclass_sfx' ) ?>">
<?php echo modBannersHelper::renderBanner($params, $item2);?>
<div class="clr"></div>
</div>
</td>
</tr>
<?php endfor;?>
</table>
finbiro
Forum Newbie
Posts: 2 Joined: Fri Oct 03, 2008 5:58 am
Post
by finbiro » Fri Oct 03, 2008 11:10 am
Not working propperly. The page blocks.
php 5.2.5 / Joomla! 1.5
This is module called mod_banners.
The zipped file is in attachment if it helps.
Attachments
mod_banners.zip
(4.91 KiB) Downloaded 14 times