MDN

Go Back   Mambo - Forums Closed for posting > Mambo 4.5.5 - Stable > General Questions

Reply
 
Thread Tools Search this Thread Display Modes
Old September 6th, 2004, 14:01   #1
hotnuts21
 
hotnuts21's Avatar
 
Join Date: Dec 2003
Posts: 496
hotnuts21 is on a distinguished road
Default Adding gallery images to front page mod

I have got a modification that takes all the categorys from zoom gallery and adds them as small thumbnails to the front page

However it is restricted to 5 thumbnails per row, I have 7 gallerys but I only want 5 to show. I have posted the code here, can someone tell me how to restrict it so it only shows the first 5 galleries please?
It would be even better if i could pick the gallerys, but not essential.

Here is the code
PHP Code:
<?php
###################################################################################################
#  Display Latest News Headlines [21 July 2004] 
#  Alexander van Doormalen
#  avdoormalen@xs4all.nl

# Parameters:
# - column1_catid             = Category id for the first column (value: integer)
# - column1_Sectionid     = Section id for the first column (value: integer)
# - column2_catid             = Category id for the second column (value: integer)
# - column2_Sectionid     = Section id for the second column (value: integer)
# - column3_catid             = Category id for the third column (value: integer)
# - column3_Sectionid     = Section id for the third column (value: integer)
# - column4_catid             = Category id for the fourth column (value: integer)
# - column4_Sectionid     = Section id for the fourth column (value: integer)
# - maxchars        = Number of chars to display when viewing a news item. (value: integer)    

#  based on Latest News Module  
###################################################################################################

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

//css link
echo "\n<link href='./modules/mod_cus_zgi/gallery_index.css' rel='stylesheet' type='text/css'>\n";

//display 4 columns
displayCategories();


//get detailed news item fron list
function displayCategories()
{
    global 
$database;
            
    
//query
    
$sQuery  "SELECT cat.catid, cat.catname, cat.catdir, img.imgfilename FROM #__zoom AS cat ";
    
$sQuery .= "LEFT JOIN #__zoomfiles AS img ON (cat.catid=img.catid) WHERE cat.published=1 ";
    
$sQuery .= "AND (img.published=1 OR img.published IS NULL) AND cat.subcat_id=0 ";
    
$sQuery .= "GROUP BY cat.catname ORDER BY cat.catname";

    
//do query and fetch result
    
$database->setQuery($sQuery);
    
$aRows $database->loadObjectList();
            
    if(!isset(
$aRows[0]))
    {
        echo 
"no categories found!";
        return;
    }
    
    
$aHTML = array();
    
$sCategories "";
    
$iPos 0;
    
    for(
$iRow 0$iRow sizeof($aRows); $iRow++)
    {        
        
$sHeader     "<div class='title'>" createCategoryLink($aRows[$iRow]) . "</div>\n";
        
$sImage        "<div class='image'>" createCategoryLink($aRows[$iRow], createTumbnail($aRows[$iRow])) .  "</div>\n";    
        
        
$aHTML[$iPos]['header'] .= $sHeader;
        
$aHTML[$iPos]['image']     .= $sImage;
        
        if((
$iRow 1) % == 0)
            
$iPos++;    
    }
        
    for(
$iRow 0$iRow sizeof($aHTML); $iRow++)
    {
        echo 
"<div class='headerRowContainer'><div class='headerRow'>\n";
        echo 
$aHTML[$iRow]['header'];
        echo 
"</div></div>";
        
        echo 
"<div class='imageRowContainer'><div class='imageRow'>\n";
        echo 
$aHTML[$iRow]['image'];
        echo 
"</div></div>";
    }    
}

function 
createCategoryLink(&$cCategory$sText "")
{
    
$sLink "<a href='"sefRelToAbs("index.php?option=com_zoom&amp;catid=" $cCategory->catid) . "'>";
    
$sLink .= !empty($sText) ? $sText :$cCategory->catname;
    
$sLink .= "</a>";
    
    return 
$sLink;
}

function 
createTumbnail(&$cCategory
{
    global 
$mosConfig_absolute_path$database;

    
$iImgCount 0;
    
    if(!empty(
$cCategory->imgfilename))
    {
        
$sFile "/images/zoom/{$cCategory->catdir}/thumbs/{$cCategory->imgfilename}";    
        
        
$sQuery  "SELECT COUNT(imgid) AS count FROM #__zoomfiles WHERE published=1 AND catid=" $cCategory->catid;
    
        
$database->setQuery($sQuery);
        
$aRows $database->loadObjectList();    
        
        if(isset(
$aRows[0]))    
            
$iImgCount $aRows[0]->count;
    }
    else 
        
$sFile "/components/com_zoom/images/noimg.gif";    
    
    
$sSize "";
    
    if(
function_exists('getimagesize'))
    {
        
$aSize = @getimagesize($mosConfig_absolute_path $sFile);
        
        if(
is_array($aSize)) 
            
$sSize "width='{$aSize[0]}' height='{$aSize[1]}'";
    }    
    
    
$sImage"<img src='.{$sFile}' {$sSize} alt='{$iImgCount} image(s)' class='tumbnail'/>";
                
    return 
$sImage;
}

?>
hotnuts21 is offline   Reply With Quote
Old September 11th, 2004, 11:55   #2
hotnuts21
 
hotnuts21's Avatar
 
Join Date: Dec 2003
Posts: 496
hotnuts21 is on a distinguished road
Default

Anyone got an idea on how to do this?
hotnuts21 is offline   Reply With Quote
Old September 13th, 2004, 12:31   #3
sim2k
 
Join Date: Sep 2004
Posts: 7
sim2k is on a distinguished road
Default

Hi,
maybe it works like this:
Code:
    $sQuery  = "SELECT cat.catid, cat.catname, cat.catdir, img.imgfilename FROM #__zoom AS cat WHERE cat.catname != YOUR CATNAME ";
sim2k is offline   Reply With Quote
Old September 13th, 2004, 14:47   #4
hotnuts21
 
hotnuts21's Avatar
 
Join Date: Dec 2003
Posts: 496
hotnuts21 is on a distinguished road
Default

Yeah that might work
hotnuts21 is offline   Reply With Quote
Old September 13th, 2004, 16:06   #5
hotnuts21
 
hotnuts21's Avatar
 
Join Date: Dec 2003
Posts: 496
hotnuts21 is on a distinguished road
Default

Hmm i changed the sql query
PHP Code:
//query
    
$sQuery  "SELECT cat.catid, cat.catname, cat.catdir, img.imgfilename FROM #__zoom AS cat ";
    
$sQuery .= "LEFT JOIN #__zoomfiles AS img ON (cat.catid=img.catid) WHERE cat.published=1 ";
    
$sQuery .= "AND (img.published=1 OR img.published IS NULL) AND cat.subcat_id=0 ";
    
$sQuery .= "GROUP BY cat.catname ORDER BY cat.catname"
So that it only showed the catids that I wanted it to. So the code looked like this
PHP Code:
//query
    
$sQuery  "SELECT cat.catid, cat.catname, cat.catdir, img.imgfilename FROM #__zoom AS cat ";
    
$sQuery .= "LEFT JOIN #__zoomfiles AS img ON (cat.catid=img.catid) WHERE cat.published=1 ";
    
$sQuery .= "AND (img.published=1 OR img.published IS NULL) AND cat.subcat_id=0 ";
    
$sQuery .= "AND cat.catid=4 OR cat.catid=9 OR cat.catid=3 OR cat.catid=5 OR cat.catid=2";
    
$sQuery .= "GROUP BY cat.catname ORDER BY cat.catname"
The weird thing is that it displays No categories found, however when I run the above query in mysql as a pure sql query it works just fine. Any ideas why its not working in the above file?
hotnuts21 is offline   Reply With Quote
Old September 13th, 2004, 16:47   #6
hotnuts21
 
hotnuts21's Avatar
 
Join Date: Dec 2003
Posts: 496
hotnuts21 is on a distinguished road
Default

Fixed it, it was missing a space after catid=2
hotnuts21 is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
showing random images and posts on front page snoopy Custom Development 13 August 31st, 2004 15:27
Adding content to the front page diehlr General Questions 2 August 22nd, 2004 12:23
Adding another row in the Table displaying content on main page + images in titles q. Cryptor Custom Development 0 August 19th, 2004 00:34
No images in Front Page News items old_mac Administration Questions 3 July 31st, 2004 10:37
Problem adding content to front page fireboat786 Administration Questions 2 May 31st, 2004 22:19


All times are GMT -7. The time now is 08:06.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.