Support Forums

Problems with Tag Cloud

This is a discussion on Problems with Tag Cloud within the Modules / Plugins / Modifications forums, part of the Developer Forums category; Help: http://www.68classifieds.com/forums/showthread.php?t=4581 I think I know the answer to 2. in that main categories are not attributed with the number ...


Go Back   68 Classifieds Forums > Developer Forums > Modules / Plugins / Modifications

Reply
 
Thread Tools Display Modes
Old 07-24-2008, 05:28 PM   #1
All Hands On Deck
 
seymourjames's Avatar
 
Join Date: Mar 2008
Posts: 3,529
Rep Power: 89
seymourjames is a jewel in the rough
Default Problems with Tag Cloud

Help:

Plugin - Category Tag Cloud


I think I know the answer to 2. in that main categories are not attributed with the number of adverts in subcategories? but really need help with 1. Is it possible that my database is somehow corrupted or when I first built the site I had these categories which no longer exist?
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C
seymourjames is online now   Reply With Quote
Old 07-24-2008, 05:50 PM   #2
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 136
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Try this...

Replace the full plugin code with the following:
PHP Code:
<?php
function smarty_function_categories_cloud($params, &$smarty)
{
    global 
$db,$arr_childs$Categories;
    
    
$min '.9';
    
$max '5';
    
$pixel 'em';
    
$output '<div id="tagcloud">'"\n";
    
    foreach (
$params as $_key=>$_value)
    {
        switch (
$_key)
        {
            case 
'max':
            case 
'min':
            case 
'pixel':
                $
$_key $_value;
                break;
        }
    }
    
    
// First get the total//
    
$sSQL2="SELECT COUNT(*) AS total FROM ".PREFIX."listings WHERE expiration > NOW() AND display = 'Y'";
    
$result2=$db->query($sSQL2);
    
$rs2=$result2->fetch();
    
$total_listings=$rs2['total'];
    
    
//now loop the categories and get the percentage.
    
$sSQL "SELECT id,parent_id,name,slug,allowads,cLink FROM ".PREFIX."categories WHERE display<>'N' ORDER BY cORDER DESC, name ASC";
    
$result=$db->query($sSQL);
    if(
$result->size() > 0)
     {
        
$i=0;
        while (
$rs=$result->fetch())
        {
            
$name=safeStripSlashes($rs['name']);
            
$name=htmlspecialchars($name);
            
//add url for category link
            
if($rs['cLink']<>"")
            {
                
$start_link='<a href="'.$rs['cLink'].'">';
            }
            else
            {
                
$slug = ( empty($rs['slug']) ) ? $rs['id']: $rs['slug'];
                
$start_link='<a href="category.php?cat='.$slug.'">';
            }
            
            
$sSQL2="SELECT COUNT(*) AS size FROM ".PREFIX."listings WHERE section = "$rs['id'] ." AND expiration > NOW() AND (display='Y' OR display='S')";
            
$result2=$db->query($sSQL2);
            
$row $result2->fetch();
            
$cat_total=$row['size'];
            
$size $cat_total $total_listings;
            
$size $size $max;
            if(
$size $min)
            {
                
$size $min;
            }
            if(
$size $max)
            {
                
$size $max;
            }
            
//output
            
$output.='<span style="font-size: '.$size $pixel.'">'.$start_link $name .'</a></span>'"\n";
        }
        
$result->freeResult($result);
        
$output .= '</div>'"\n";
        return 
$output;
     }
     else
     {
         return 
false;
     }
}
?>
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 07-24-2008, 06:03 PM   #3
All Hands On Deck
 
seymourjames's Avatar
 
Join Date: Mar 2008
Posts: 3,529
Rep Power: 89
seymourjames is a jewel in the rough
Default

Thanks Eric.

I ran myphpadmin and found out that I had some old categories which I never used but these were being picked up by the mysql query. I have deleted them and therefore 1. is no longer a problem. The admin control panel appears not be deleting categories from the database though even though you think you have deleted them. It may be something to look into for a future release.

As for number 2, will your module now solve the issue of main categories (where you cannot place adverts in my case) being attributed with the cumulative total of listings in their subcategories. That way, the main categories will get bigger text in the cloud.

Thanks
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C
seymourjames is online now   Reply With Quote
Old 07-24-2008, 06:18 PM   #4
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 136
Eric Barnes is just really nice Eric Barnes is just really nice
Default

No for #2 you would have to do some type of join or way to add it to the parent. Not very easy I don't think.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 07-24-2008, 07:30 PM   #5
All Hands On Deck
 
seymourjames's Avatar
 
Join Date: Mar 2008
Posts: 3,529
Rep Power: 89
seymourjames is a jewel in the rough
Default

Still with the rand() function it works well to include this tag cloud on potentially duplicate pages (e.g. showlistings with < 3 listings) or empty pages coming from searches and categories with nothing in them.

Were you aware the admin panel it may not be deleting categories in the database tables?

If I find a solution to combining categories or some weighting system I will post it here.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C
seymourjames is online now   Reply With Quote
Old 07-28-2008, 06:53 AM   #6
All Hands On Deck
 
seymourjames's Avatar
 
Join Date: Mar 2008
Posts: 3,529
Rep Power: 89
seymourjames is a jewel in the rough
Default

Here is a nice function to make all pages unique to some degree. The sizes of the entries in the tag cloud are now randomized and so is the order in which they appear. It is also fairly easy to tweek this function further so that the number of entries is randomized as well (I have done that on my actual site). The chances of getting the same combination on any page is remote. To the search engines, duplicate pages start to look a bit different even if they contain similar info within them. The links also have title tags on them as well.

See the affect here by pressing the refresh button or visiting another category or two.

French Properties For Sale

Here is the function

<?php
function smarty_function_categories_cloud($params, &$smarty)
{
global $db;
//set a min and max for randomising the font size plus a convenient divisor to scale the font size.
$min = '1';
$max = '8';
$divisor = '5';
//set a random number of categories to display - I chhoose a number between 10 and 28
$numberofcats = rand(10,28);
$pixel = 'em';
$output = '<div id="tagcloud">'. "\n";

foreach ($params as $_key=>$_value)
{
switch ($_key)
{
case 'max':
case 'min':
case 'pixel':
$$_key = $_value;
break;
}
}

//now loop the random ordered categories upto your random number of categories and randomise size of the links.
$i = 0;
$sSQL = "SELECT id,parent_id,name,slug,allowads,cLink FROM ".PREFIX."categories WHERE display<>'N' ORDER BY Rand(), name ASC";
$result=$db->query($sSQL);
if($result->size() > 0)
{
while (($rs=$result->fetch()) && ($i <= $numberofcats))
{
$i = $i + 1;
$name=safeStripSlashes($rs['name']);
$name=htmlspecialchars($name);
//add url for category link
if($rs['cLink']<>"")
{
$start_link='<a href="'.$rs['cLink'].'">';
}
else
{
$slug = ( empty($rs['slug']) ) ? $rs['id']: $rs['slug'];
$start_link='<a href="category.php?cat='.$slug.'" title="'.$name.'">';
}

$size = rand($min,$max)/$divisor;
if($size < $min)
{
$size = $min;
}

//output
$output.='<span style="font-size: '.$size . $pixel.'">'.$start_link . $name .'</a></span>'. "\n";
}
$output .= '</div>'. "\n";
return $output;
}
else
{
return false;
}
}
?>
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C

Last edited by seymourjames; 07-28-2008 at 03:36 PM. Reason: minr mod required to test on minimum size or firefox makes strange font-size
seymourjames is online now   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plugin - Category Tag Cloud Eric Barnes Modules / Plugins / Modifications 12 05-11-2010 01:49 PM
Log In Problems Kazza Technical Support 17 06-03-2008 03:38 PM


All times are GMT -4. The time now is 05:40 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0