PDA

View Full Version : Latest image in the sections


HeavyEddie
01-22-2006, 07:26 PM
This will allow you to display the latest image along with the section title and description. You can see an example at http://www.geochums.com/gallery. After all... an image is worth a thousand words.

Find this...
// ########################## GET SECTION IMAGE COUNT ##########################

And place this just above...
// ########################## GET Latest Section Image ##########################

function p17_GetLatestSectionImage($sectionid)
{
**global $DB;

**$result = $DB->query("SELECT imageid, sectionid, filename FROM " . TABLE_PREFIX . "p17_images WHERE sectionid = " . $sectionid . " AND activated = '1'" . " ORDER BY imageid" . " DESC LIMIT " . "1" . "");

**$row = mysql_fetch_array($result, MYSQL_ASSOC);
**if($row['filename'] == "")**{$row['filename'] = "noimage.jpg";}
******
**return $row['filename'];
}


Next, find this...
**// display subsections
**while($subsection = $DB->fetch_array($getsubsections))
**{
****$numsectionimages = p17_GetSectionImageCount($subsection['sectionid'], 0);

****echo '- <b><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p17_sectionid=' . $subsection['sectionid']) . '">'.$subsection['name'].'</a></b> ('.$numsectionimages.')
************<br />' . nl2br($subsection['description']);

****if(strlen($subsection['description']) > 0)
****{
******echo '<br />';
****}

****echo '<br />';
**}


And replace it with this...
**// display subsections
**echo '<br><table>';
**while($subsection = $DB->fetch_array($getsubsections))
**{
****$numsectionimages = p17_GetSectionImageCount($subsection['sectionid'], 0);
****echo '<tr><td width="110" height="85"><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p17_sectionid=' . $subsection['sectionid']) . '"><img src="' . $sdurl . 'plugins/p17_image_gallery/images/tb_' . p17_GetLatestSectionImage($subsection['sectionid'] ) . '"></td>';
****echo '<td valign=top>';
****echo '<b><a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p17_sectionid=' . $subsection['sectionid']) . '">'.$subsection['name'].'</a></b> ('.$numsectionimages.')
**********<br>**' . nl2br($subsection['description']);
****echo '</td></tr>';
**}
**echo '</tr></table>';


Make sure you save an image called "tb_noimage.jpg" and place it in your images directory. This is what will be displayed if there isn't any images in the section.

t3chb0y
01-30-2006, 07:31 AM
awesome 5 stars ^_^

HeavyEddie
05-16-2006, 04:01 AM
I'm adapting this to work with 2.3. I've added a little twist and am doing it in conjuction with overlib. Still a little work to be done... but pretty cool if I do say so myself.

Mouse over a section image to see the affect.
http://www.geochums.com/gallery/p17_sectionid/1

gdogg2000
10-28-2006, 03:37 PM
Im confused.. why the asterisks? that doesnt show up on any other code.. I deleted them but it doesnt work.. are they required some how?

HeavyEddie
10-28-2006, 04:20 PM
No... I guess the asterisks were put in when the board went from IPB to VB. Please-double check... that you pulled out only astericks... this does work.