PDA

View Full Version : Component to display banners in content


webfitz
12.04.2004, 17:36
I want to develop a component that will display the banners in the main body rather than in the default banner module.
I think I know how to display the banners as content but I can't figure out how to limit the output to, say, just 15 banners on each page (there will be over 200 banners so I don't want them all showing up on the first page).
Can someone point me in the right direction?
Thanks

keliix06
12.04.2004, 19:56
SELECT * FROM banners_table WHERE whatever LIMIT 15
will limit the output to 15 results.

MamboJoe
13.04.2004, 18:53
Sounds like you'd need to use a mambot as not only would you want to limit the number of banners per page but also be able to position them with in the content. The mambot would also need paramaters for categories if you are working with one of the addon components, etc so you could determine the size of the ad as well.

webfitz
15.04.2004, 19:41
I'm not sure if I'm explaining myself very well. I have a .php script written (not that pretty but it works). The script just calls the data from the mos_banners database and displays it in a table. I saved the script as testmemberbanners.php in the mosaddphp directory. I created a typed content Main Menu item called TEC Members and just pasted the following to it:
{mosaddphp:testmemberbanners.php}

Here's the link to the output:
http://tec.xmambo.com/index.php?option=content&task=view&id=33&Itemid=113

There are only two problems:
1. The contentheading doesn't display (just the .css background colour)
2. I'm not sure how to go about limiting the output to 15 items per page

Here is the testmembersbanner.php script:


<?php
$database->setQuery( "SELECT * FROM mos_banner WHERE showBanner=1 ORDER BY name ASC");
$data = $database->loadObjectList();
echo "
<p>TEC Members vary as much as the industries in which they operate. Members range from executives of large corporations to entrepreneurs growing start-up ventures. However they all have one thing in common, they have realized the powerful effect that a membership in TEC can have on their lives.</p>
<p>Below are a few TEC Member companies who have requested to be showcased on this website.</p>
";
echo "<p><table border=1 cellspacing=0 cellpadding=2 bordercolor=#ffffff width=100%>";
echo "<tr align='center' valign='top' bgcolor='#e9e5cf'>
<td align='center' class='tecchair'><b>Logo</b></td>
<td align='center' class='tecchair'><b>Company Name</b></td>
<td align='center' class='tecchair'><b>Web Site</b></td>
</tr>";
foreach ($data as $row)
{
$logo = $row->imageurl;
$company = $row->name;
$webaddress = $row->clickurl;

if ($webaddress === null) {
echo "<tr bgcolor='#f6f4eb'><td><div align=center><img src=\"/images/banners/$logo\" border=\"0\" alt=\"Advertisement\"></div></td>
<td><div align=center>$company</div></td>
<td><div align=center></div></td></tr>
";
}
else {
echo "<tr bgcolor='#f6f4eb'><td><div align=center><a href=\"$webaddress\" TARGET=\"_blank\" border=\"0\"><img src=\"/images/banners/$logo\" border=\"0\" alt=\"Advertisement\"></a></div></td>
<td><div align=center>$company</div></td>
<td><div align=center><a href=\"$webaddress\" TARGET=\"_new\">$webaddress</a></div></td></tr>
";
}

}
echo "</table>";
?>

Can someone tell me what I'm doing wrong?

I thought that if I created a com_tecbanners component instead, these two problems would be solved. But I'm not sure how to go about doing that.
My .php coding skills are limited to say the least. Any insights would be appreciated.

BTW, the 'TEC Member Showcase' is just this code in the template file:

<?php mosLoadComponent( "banners" ); ?>

webfitz
22.04.2004, 11:23
I have not solved the problem with the pagination of the banners display - that's another day. On the client's site, I have coded the template to load the banners in the left column using :

<?php mosLoadComponent( "banners" ); ?>

Here is the site, the banners are under TEC Member's Showcase:

http://www.tec.xmambo.com/index.php?option=com_frontpage&Itemid=1

Now the client has asked me if I can display the date the Member joined under the banner image. So that would require a new date field in the banner component (like a member_in field). So, I added the field to the database; to the banners.class.php and coded a new row in the admin.banners.html.php as follows:

<tr>
<td valign="top" align="right">Date Member Joined:</td>
<td>
<input class="inputbox" type="text" name="member_in" id="member_in" value="<?php echo $row->member_in; ?>" size="46" maxlength="100" />
<input type="reset" class="button" value="..." onClick="return showCalendar('member_in', 'y-mm-dd');">
</td>

This would allow the client to add or modify the date that a new member joins up (and it could then be displayed)

The problem is that when I go to edit the banner; the new line wont' display the date info. I can input a new date and it will save to the database but when I go to edit that same row, there is no date showing.

Any ideas what I've done wrong? Have I missed something obvious?
Thanks