lots of code take some code, share some code!

Tag Cloud v2



Please check out the demo page for examples on how to use the new functions available in this version.

Some of the new features included in the new tag cloud script are:

  • Link and URL Assignment
  • Additional attribute assignment e.g. title etc
  • Add styles and colour options to each tag
  • Set a limit to the amount of tags that are displayed
  • Examples of intergrating with a MySQL Database
  • Examples of intergrating with a Flat Text File
  • String to cloud, parse a single string into a tag cloud instantly
  • Ignore list, to remove particular words from the cloud. e.g. and, the, it, i
  • Ordering by a selective field. e.g. word, size, colour

Tutorial coming soon ...

14 Responses to “Tag Cloud v2”

  1. Terkel says:

    I can't wait! I love you tag system, and this sounds very good :P Keep up the good work dude

  2. K K says:

    hi, great class! In my case I modified showCloud function a bit.

    if(strlen($arrayInfo['url'])){
    $return .= "<a href=\'{$arrayInfo[\'url\']}\' class='word size{$sizeRange}'> &nbsp; {$arrayInfo[\'word\']} &nbsp; </a>";
    }else{
    $return .= "<span class=\'word size{$sizeRange}\'> &nbsp; {$arrayInfo['word']} &nbsp; </span>";
    }

    This way I don't need to get array first and create links myself. This might be useful for other users?

  3. Arnaud says:

    I think your tutorial should also include the Rewrite Engine rule required to make the domain.dom/tag// link work :)

  4. Gabriel says:

    I had a problem with this code. I wanted to pass a load of strings into it then have it show the top 10 most popular strings. Perhaps i missed somthing.? isnt this the entire point of a TagCloud?

  5. ????? says:

    Good explane

  6. Tag Cloud . Lots of Code says:

    [...] Tag Cloud Script (Version 2) is now Available, with more customizable features [...]

  7. Bandorka says:

    There is a bug at the Limit:

    $i = 1;
    foreach ($this->wordsArray as $key => $value) {
    if ($this->limitAmount < $i) {
    $wordsArray[$value['word']] = $value;
    }
    $i++;
    }

    limitAmount $i

  8. lotsofcode says:

    @Gabriel
    When you parse a string into the tag cloud class, it converts the string to tags, you can order and limit the tags using specific methods in the class, these are shown in the tutorial.

    @Arnaud
    Good idea, although this isn't really something i can control as each site system will work differently.

    @Bandorka

    Thanks for the comment, could you please expand on this as it's very difficult for me to replicate the bug you are encountering! Looking at the code, it looks fine to me and i have tested the method and i seem to get the desired results ... ?

  9. Articles says:

    Good post!...

  10. Morticus says:

    Nice class, great work :)

    Found a bug though, and the fix I believe.

    In the getMax()-method in wordcloud.class.php a "{" and a "}" is missing.

    Before it was this:
    ...
    row 306: if ($c_size > $p_size)
    row 307: $max = $c_size;
    row 308: $p_size = $c_size;

    After my fix:
    ...
    row 306: if ($c_size > $p_size) {
    row 307: max= $c_size;
    row 308: $p_size = $c_size;
    row 309: }

    You can see the bug in action on your demo-page actually. If you view that page and just hits F5 5-10 times you will see how your first Basic Example change appearance (the order), and some times the "weight" of the tags change too. That "randomness" in tag-weight is a bug in my oppinion.

  11. lotsofcode says:

    Indeed it was a minor bug, thank you for mentioning this it is now fixed ;-) and it works a little smoother and consistent when the page is reloaded.

    As each item was looped through only two items were compared in size, now we store the largest item in size and then compare it to each item as it loops through the array.

    Thanks again!

  12. Fabulousfab says:

    Hi. I tried to limit the number of words.
    For exemple the top 10 words of a text.
    How to do ?

  13. balloon says:

    Hi,

    I was wondering how I would go about using an RSS feed as the data source for your cloud script?

    Any help you could provide would be greatly appreciated.

    All the best.

  14. kwan2400 says:

    Hi,
    Thank you for your script!

    Could You show me an example what is about W/Links & colours MySQL Database?

    If there are three fileds of word, link, color.

    Thank you!

Leave a Reply

 
 
Please enter the word above into the box below, the word is not case sensitive.
 
If you have trouble reading the word above then click here to load a new word.
Security word: