Support Forums


Go Back   68 Classifieds Forums > Help & Support > Modules / Plugins / Modifications

Notices

 
LinkBack Thread Tools Display Modes
Old 07-24-2008, 04:28 PM   #1
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,052
Rep Power: 28
seymourjames has a spectacular aura about
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?
__________________
TemplateCodes.com
seymourjames is online now   Reply With Quote
Old 07-24-2008, 04:50 PM   #2
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,020
Rep Power: 116
Eric Barnes is a jewel in the rough
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
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 07-24-2008, 05:03 PM   #3
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,052
Rep Power: 28
seymourjames has a spectacular aura about
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
__________________
TemplateCodes.com
seymourjames is online now   Reply With Quote
Old 07-24-2008, 05:18 PM   #4
68 Classifieds Staff
 
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,020
Rep Power: 116
Eric Barnes is a jewel in the rough
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
Please do not send me a private message asking for support. Instead use these open forums or our ticket system.

Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 07-24-2008, 06:30 PM   #5
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,052
Rep Power: 28
seymourjames has a spectacular aura about
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.
__________________
TemplateCodes.com
seymourjames is online now   Reply With Quote
Old 07-28-2008, 05:53 AM   #6
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 1,052
Rep Power: 28
seymourjames has a spectacular aura about
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;
}
}
?>
__________________
TemplateCodes.com

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

Bookmarks

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plugin - Category Tag Cloud Eric Barnes Modules / Plugins / Modifications 8 01-12-2009 03:14 PM
Log In Problems Kazza v4 Questions & Support 17 06-03-2008 02:38 PM
Image upload problems... Mikael v3.1 Questions & Support 13 02-22-2007 08:46 AM
Problems with updateOrder function flyingpylon v3.1 Questions & Support 3 11-06-2006 08:58 PM
If your having problems after an upgrade... From old forum calaf6 v3.0 Questions & Support 0 03-30-2006 04:44 PM


All times are GMT -4. The time now is 03:24 AM.


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