Support Forums

Plugin - Category Tag Cloud

This is a discussion on Plugin - Category Tag Cloud within the Modules / Plugins / Modifications forums, part of the Developer Forums category; v4 Plugin - Category Tag Cloud This smarty plugin will create a tag cloud of your categories. Requirements Minimum version ...


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

Reply
 
Thread Tools Display Modes
Old 04-01-2008, 02:51 PM   #1
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 134
Eric Barnes is just really nice Eric Barnes is just really nice
Default Plugin - Category Tag Cloud

v4 Plugin - Category Tag Cloud

This smarty plugin will create a tag cloud of your categories.

Requirements

Minimum version 4.0.0

Instructions

Save the code below as function.categories_cloud.php and place it in the includes/classes/smarty/plugins/ folder.

After you have saved the file you can use this code in the template file:
Code:
{categories_cloud}
You will also need to add another style to your css file. Something like this:
Code:
#tagcloud { margin: 0 0 20px; }
#tagcloud a { margin: 0 5px 0 0; color: #25771F; }
#tagcloud a:hover { background: #E7FEE5; color: #007898; }
Parameters

Below is a list of parameters you can use when calling this plugin. Please note these are optional.

min(integer)
The minimum size for the category with the least listings.
max(integer)
The maximum size for the category with the most listings.
pixel(string)
What size you want. Default is "em". Could be % or px.

Download
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//
    
$sSQL="SELECT COUNT(*) AS total FROM ".PREFIX."listings WHERE expiration > NOW() AND display = 'Y'";
    
$result=$db->query($sSQL);
    
$rs=$result->fetch();
    
$total_listings=$rs['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

Last edited by Eric Barnes; 04-01-2008 at 03:17 PM.
Eric Barnes is offline   Reply With Quote
Old 04-01-2008, 03:36 PM   #2
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,342
Rep Power: 51
Maffo is just really nice Maffo is just really nice
Default

Call me an idiot but what is a tag cloud?
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 04-01-2008, 03:42 PM   #3
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 134
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Here is an example of one: http://ajaxrain.com/tagcloud.php

I have seen them on lots of blogs and such. So I thought it would be something someone might want.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 04-01-2008, 04:43 PM   #4
The Master
 
Maffo's Avatar
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,342
Rep Power: 51
Maffo is just really nice Maffo is just really nice
Default

Thanks Eric, yet another geek name to add to my vocabulary
__________________
**Bulk Upload System** has been upgraded. Works on all v4 versions with new functionality. Free upgrade for existing customers.
Maffo is offline   Reply With Quote
Old 06-19-2008, 05:21 AM   #5
Senior Member
 
CHRD's Avatar
 
Join Date: Nov 2006
Posts: 191
Rep Power: 23
CHRD is on a distinguished road
Default

this tag cloud is listing all 420 of my cats
__________________
Costa del Sol
Spain
V4.18 Dev
�Powerful you have become, the dark side I sense in you.�
CHRD is offline   Reply With Quote
Old 06-19-2008, 06:55 AM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 134
Eric Barnes is just really nice Eric Barnes is just really nice
Default

You can just add a limit to the query:

Code:
FROM ".PREFIX."categories WHERE display<>'N' ORDER BY cORDER DESC, name ASC LIMIT 20";

__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 06-19-2008, 12:49 PM   #7
Member
 
Join Date: Apr 2006
Posts: 76
Rep Power: 23
gppromano is on a distinguished road
Default

I use version 3.1.5 how can I make it compatible?

Thanks
gppromano is offline   Reply With Quote
Old 09-08-2008, 03:05 AM   #8
Customer
 
Join Date: Sep 2008
Posts: 2
Rep Power: 0
manchag is on a distinguished road
Exclamation Display cities in the tag cloug

Hello everyone,
i'm having some problems installing this script. I followed all the steps, however all the tags look the same size:
Enlistalo - Anuncios Clasificados en tu Localidad

I was also wondering if it's possible to customize this script and display cities instead of categories?


Manuel
manchag is offline   Reply With Quote
Old 01-12-2009, 03:14 PM   #9
Customer
 
Join Date: Aug 2008
Posts: 80
Rep Power: 13
nagrap2 is on a distinguished road
Default Display Sub Categories Only

Eric,

How can I modify this script so that it only displays the Sub Categories for the Category I am viewing?

I would want to do something similar to the following, where the user clicks on a top level category and then I display the Cloud of subcategories:

School of Everything | Learn drawing

Thanks in advance...
__________________
Many Thanks,

Nagrap2

Developer Version 4.1
nagrap2 is offline   Reply With Quote
Old 02-01-2010, 09:23 PM   #10
Customer
 
damiun's Avatar
 
Join Date: Apr 2009
Posts: 412
Rep Power: 18
damiun is on a distinguished road
Default

Where do I have to place
Quote:
FROM ".PREFIX."categories WHERE display<>'N' ORDER BY cORDER DESC, name ASC LIMIT 20";
to limit the results?

Dominick
damiun is offline   Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 11:16 AM.


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