• [MOD] Tag cloud ( keyword & cat cloud in web2.0 style) 5 0 5 1
Currently:  

Poll

What do you think of this mod?

Excellent
Good
Fair
Poor
Bad

Author Topic: [MOD] Tag cloud ( keyword & cat cloud in web2.0 style)  (Read 211339 times)

0 Members and 1 Guest are viewing this topic.

Offline ch€ri{Bi}˛

  • Sr. Member
  • ****
  • Posts: 315
  • A PRoBLeM wIthOUt SoLuTioN Is NoT rEAllY a PRoBLeM
    • View Profile
    • Pat's Gallery
[MOD] Tag cloud ( keyword & cat cloud in web2.0 style)
« on: March 06, 2007, 11:22:02 PM »
hi all,

this is a version of the tag clouds  8) for 4images...
this little mod display a cloud of keyword (see here for categories), sort by quantity (the more the keyword is used in the gallery, bigger will be the font).
 :!: only real keywords : i mean no keywords from name or description
you can see a demo on my site.

first : backup your files and

STEP1 : open includes/page_header.php
and add at the very end before ?>:
Code: [Select]
$site_template->register_vars(array(
  "lang_keyword" => $lang['keywords'], //---[/[MOD] Tag Clouds]
  "show_tag_clouds" => get_tag_clouds() //---[/[MOD] Tag Clouds]
));

STEP2 : open includes/functions.php
and add at the very end before ?>:
Code: [Select]
//---[ [MOD] Tag Cloud]
function get_tag_clouds() {
global $site_db, $lang, $site_sess, $mode;
$output = "";
   
  $sql = "SELECT i.word_id, i.word_text, COUNT(c.word_id) AS quantity
  FROM ".WORDLIST_TABLE." i
LEFT JOIN ".WORDMATCH_TABLE." c ON i.word_id = c.word_id
WHERE keys_match > 0
  GROUP BY i.word_text
  ORDER BY  RAND()
LIMIT 20";

  $result = $site_db->query($sql);
  while ($row = $site_db->fetch_array($result)) {
    $tags[$row['word_text']] = $row['quantity'];
  }
 
  //uncommentnext line to sort the tag array in reverse order (+ => -)
   //arsort($tags);   
        $max_size = 250; // max font size in %
        $min_size = 50; // min font size in %
       
        // largest and smallest array values
        $max_qty = max(array_values($tags));
        $min_qty = min(array_values($tags));
       
        // find the range of values
        $spread = $max_qty - $min_qty;
        if ($spread == 0) { // we don't want to divide by zero
                $spread = 1;
        }
       
        // set the font-size increment
        $step = ($max_size - $min_size) / ($spread);
       
        // loop through the tag array
        foreach ($tags as $key => $value) {
                // calculate font-size
                // find the $value in excess of $min_qty
                // multiply by the font-size increment ($size)
                // and add the $min_size set above
                $size = round($min_size + (($value - $min_qty) * $step));
       
                $output .= '<a href="'.$site_sess->url(ROOT_PATH."search.php?search_keywords=".$key.((!empty($mode)) ? "&amp;mode=".$mode : "")).'" style="font-size:'.$size.'%;color:rgb('.mt_rand(0, 255).', '.mt_rand(0, 255).', '.mt_rand(0, 255).');font-family:Verdana, Arial, Helvetica, sans-serif;" title="'.$value.' '.$lang['tagged_with'].' '.$key.'">'.$key.'</a> ';
        }

 
  return $output;
}
//---[/[MOD] Tag Cloud]
read the comments and change some setting and styles to fit your needs  :wink:

last step , open main.php in your language dir and add at the end:
Code: [Select]
$lang['tagged_with'] = "image(s) with tag: ";

now add the 2 tags {lang_keyword} and {show_tag_clouds}  anywhere in you template.

PS: for all the users who love statistics, the cloud tag can take other parameters than mine... just found the query and change it in function.php
 :idea:  :arrow: see here to find how to do this tag cloud with categories
« Last Edit: June 03, 2007, 12:31:38 PM by ch€ri{Bi}˛ »
ch€ri{Bi}˛


Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #1 on: March 07, 2007, 12:58:14 AM »
... Excellent MOD ...  :D
... it works perfect ... thanks ch€ri{Bi}˛ ...
... moved to Mods & Plugins (Releases & Support)
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #2 on: March 07, 2007, 09:55:15 AM »
nice mod!
thank you very much!

manurom

  • Guest
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #3 on: March 07, 2007, 10:41:00 AM »
Joli coup, messire ch€ri{Bi}˛ !
Adopté d'office. Mille mercis.

Offline BartAfterDark

  • Hero Member
  • *****
  • Posts: 520
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #4 on: March 07, 2007, 11:35:47 AM »
It works ;-) Looks really nice.
« Last Edit: March 07, 2007, 01:43:33 PM by BartAfterDark »

Offline drastx

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #5 on: March 07, 2007, 02:32:19 PM »
Yeah, this mod is looking good, and working really good :)
Thx for this mod!
I see that, the colors are random, how can i change them to light colors?
I have a dark site, and dark (for ex. brown) colors are barely visible...

Thx for teh mod! :)

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #6 on: March 07, 2007, 03:07:00 PM »
@ drastx

... for light colors change the rgb color code ...
... change all "0" to e.g. "100" ... or try another value ...
Code: [Select]
color:rgb('.mt_rand(0, 255).', '.mt_rand(0, 255).', '.mt_rand(0, 255).');
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline kai

  • Administrator
  • Addicted member
  • *****
  • Posts: 1.412
    • View Profile
    • 4images - Image Gallery Management System
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #7 on: March 07, 2007, 06:25:01 PM »
Great work!
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline baseline

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #8 on: March 07, 2007, 11:55:00 PM »
Super Job!

hier ein beispiel wie man es einsetzten kann (auf unserem testsystem)

http://newshuttle.pictureshuttle.com/

gruss sascha

Offline killrobot

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #9 on: March 08, 2007, 01:00:25 AM »
I always get these errors when trying to install this mod?

[07-Mar-2007 17:02:40] PHP Parse error:  syntax error, unexpected T_STRING in /Applications/MAMP/htdocs/includes/functions.php on line 1725
[07-Mar-2007 17:24:45] PHP Parse error:  syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /Applications/MAMP/htdocs/includes/page_header.php on line 373

Any suggestions?  It looks really cool and I'd really like to get it working  :D

Offline killrobot

  • Pre-Newbie
  • Posts: 2
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #10 on: March 08, 2007, 01:52:56 AM »
nevermind, i got it working!

Offline FunnyUser

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #11 on: March 09, 2007, 01:20:50 AM »
I thank you so much! I've been looking ages for this [MOD] !
It works perfectly with my 4images Version: 1.7.4 .


Thanks a lot!

FunnyUser

Offline om6acw

  • Full Member
  • ***
  • Posts: 187
    • View Profile
    • My Animal's World
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #12 on: March 09, 2007, 03:02:21 AM »
Great mod ch€ri{Bi}˛, thanks !!!

Offline Bugfixed

  • Jr. Member
  • **
  • Posts: 95
    • View Profile
    • http://www.lavinya.net
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #13 on: March 12, 2007, 02:43:20 PM »
hello all. thanks for nice mod :)

But turkish
Code: [Select]
ü, Ü, ö, Ö, i, İ letter,
wrong display: ue
example: ueniversitesi  to üniversitesi
example: koy to köy
example: irmak to ırmak
how to fix.?
my gallery charset: iso-8859-9 turkish
db collation : latin1-swedish

demo gallery


more info turkish letters
http://en.wikipedia.org/wiki/Turkish_alphabet
« Last Edit: March 12, 2007, 05:23:02 PM by Bugfixed »
<?php Find Bug ?>

rinaldos

  • Guest
Re: [MOD] Tag cloud (or keyword cloud in web2.0)
« Reply #14 on: March 13, 2007, 10:56:44 AM »
Hello ch€ri{Bi}˛

This is a wonderfull MOD. And with Mawenzi's Tip not so colorfull :-) Great work.

Thanks a lot...

Ingo