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.
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.