Plugin - Category Tag Cloud

This is a discussion on Plugin - Category Tag Cloud within the Module Release forums, part of the Help & Support 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 > Help & Support > Module Release

 
LinkBack (1) Thread Tools Display Modes
  #1  
Old 04-01-2008, 03:51 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,063
Rep Power: 93
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
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 | Submit a Ticket | Twitter

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

Call me an idiot but what is a tag cloud?
__________________
Super Mod v4 coming very, very soon

Visit Me @ Classified-Sofware.co.uk

**Important** - All modules with the exceptions of the Bulk Upload System will be removed from my modshop on Tuesday September 30th. If you require a module you must get it before that date.
Reply With Quote
  #3  
Old 04-01-2008, 04:42 PM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,063
Rep Power: 93
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
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 | Submit a Ticket | Twitter
Reply With Quote
  #4  
Old 04-01-2008, 05:43 PM
Maffo's Avatar
The Master
 
Join Date: Mar 2006
Location: British in Argentina
Posts: 1,394
Rep Power: 40
Default

Thanks Eric, yet another geek name to add to my vocabulary
__________________
Super Mod v4 coming very, very soon

Visit Me @ Classified-Sofware.co.uk

**Important** - All modules with the exceptions of the Bulk Upload System will be removed from my modshop on Tuesday September 30th. If you require a module you must get it before that date.
Reply With Quote
  #5  
Old 06-19-2008, 06:21 AM
CHRD's Avatar
Senior Member
 
Join Date: Nov 2006
Posts: 159
Rep Power: 12
Default

this tag cloud is listing all 420 of my cats
__________________
Costa del Sol
Spain
v3.1.10 Dev
V4.04 Dev sweeeet
�Powerful you have become, the dark side I sense in you.�
Reply With Quote
  #6  
Old 06-19-2008, 07:55 AM
68 Classifieds Staff
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,063
Rep Power: 93
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
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 | Submit a Ticket | Twitter
Reply With Quote
  #7  
Old 06-19-2008, 01:49 PM
Member
 
Join Date: Apr 2006
Posts: 70
Rep Power: 12
Default

I use version 3.1.5 how can I make it compatible?

Thanks
Reply With Quote
  #8  
Old 09-08-2008, 04:05 AM
Junior Member
 
Join Date: Sep 2008
Posts: 1
Rep Power: 0
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
Reply With Quote
  #9  
Old 09-08-2008, 06:10 AM
Moderator
 
Join Date: Mar 2008
Posts: 480
Rep Power: 13
Default

Try this - it adds a twist to the category cloud. It sets a random number of categories to put in the cloud, puts them in a random order to display and randomises the font size. At the least the answer is there to set your font sizes appropriately. Your problem is probably to do with the fact that you are not differentiating the categories enough based on their number of entries to vary the font sizes (trial and error to resolve that) or there simply is not enough variation in the number of listings in them.

Classifieds Scripts

You can see an example of a category cloud here at the bottom of the page where I force an empty search. You will also note that I fill the page with random listings which is a function that is also given in the downloads folder that I offer.

French Property - properties - homes - houses

Good luck
__________________
Version 4.09 - Running A Business In France
french property for sale
french property classifieds

Last edited by seymourjames; 09-08-2008 at 12:37 PM.
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

LinkBacks (?)
LinkBack to this Thread: http://www.68classifieds.com/forums/module-release/4581-plugin-category-tag-cloud.html
Posted By For Type Date
68 Mods Category Tag Cloud This thread Refback 09-03-2008 12:25 AM

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding 'category' to 'new listings' display Chaslie v3.1 Modules & Modifications 5 01-31-2008 04:31 PM
Hide a category on public pages? HotAir v3.1 Questions & Support 6 12-05-2007 11:17 AM
Branding each Category BABBSELA v3.1 Modules & Modifications 0 02-10-2007 02:17 PM
Show the visitors which category has new ads pat01 v3.1 Modules & Modifications 7 07-28-2006 02:25 AM
Category problem dawyatt v3.1 Questions & Support 2 05-24-2006 04:58 PM


All times are GMT -4. The time now is 10:19 PM.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22