Table of Contents

cloud(): Tag cloud

Mulder made some code to display a tag cloud in the template.

CODE

Here is the code (with some explanation in it) to put in CMS.PHP (functions.php) or better include as an external file and then call in template.htm:

// not part of cmsimple ©mulder - free to use - no support
function cloud(){
// copy in cms.php & call in template with cloud();
global $cf; // cmsimplecontent
$a = array_count_values(preg_split('/\s*[\s+\.|\?|,|(|)|\-+|\'|\"|=|;|×|\$|\/|:|{|}]\s*/i', strtolower(strip_tags(content()))));
$stopwords = array( '', 'a', 'an', 'the', 'and', 'of', 'i', 'to', 'is', 'in', 'with', 'for', 'as', 'that', 'on', 'at', 'this', 'my', 'was', 'our', 'it', 'you', 'we', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '10', 'about', 'after', 'all', 'almost', 'along', 'also', 'amp', 'another', 'any', 'are', 'area', 'around', 'available', 'back', 'be', 'because', 'been', 'being', 'best', 'better', 'big', 'bit', 'both', 'but', 'by', 'c', 'came', 'can', 'capable', 'control', 'could', 'course', 'd', 'dan', 'day', 'decided', 'did', 'didn', 'different', 'div', 'do', 'doesn', 'don', 'down', 'drive', 'e', 'each', 'easily', 'easy', 'edition', 'end', 'enough', 'even', 'every', 'example', 'few', 'find', 'first', 'found', 'from', 'get', 'go', 'going', 'good', 'got', 'gt', 'had', 'hard', 'has', 'have', 'he', 'her', 'here', 'how', 'if', 'into', 'isn', 'just', 'know', 'last', 'left', 'li', 'like', 'little', 'll', 'long', 'look', 'lot', 'lt', 'm', 'made', 'make', 'many', 'mb', 'me', 'menu', 'might', 'mm', 'more', 'most', 'much', 'name', 'nbsp', 'need', 'new', 'no', 'not', 'now', 'number', 'off', 'old', 'one', 'only', 'or', 'original', 'other', 'out', 'over', 'part', 'place', 'point', 'pretty', 'probably', 'problem', 'put', 'quite', 'quot', 'r', 're', 'really', 'results', 'right', 's', 'same', 'saw', 'see', 'set', 'several', 'she', 'sherree', 'should', 'since', 'size', 'small', 'so', 'some', 'something', 'special', 'still', 'stuff', 'such', 'sure', 'system', 't', 'take', 'than', 'their', 'them', 'then', 'there', 'these', 'they', 'thing', 'things', 'think', 'those', 'though', 'through', 'time', 'today', 'together', 'too', 'took', 'two', 'up', 'us', 'use', 'used', 'using', 've', 'very', 'want', 'way', 'well', 'went', 'were', 'what', 'when', 'where', 'which', 'while', 'white', 'who', 'will', 'would', 'your');
foreach ($stopwords as $word) unset( $a[$word] );
// ksort( $a );  //uncomment if you want sort the table result
$out='<p class=cloud>'; // you can set a class in .css called cloud
foreach ($a as $word => $count) {
// make the % size depends of count
 if ($count <= 3) {$size = 75;}
  elseif ($count <= 4) {$size = 100;}
  elseif ($count <= 5) {$size = 125;}
  elseif ($count <= 6) {$size = 150;}
  elseif ($count <= 10) {$size = 175;}
  elseif ($count <= 20) {$size = 200;}
 else $size = 225 ;
// keyword needs to be referenced $count times & have length >2
 if(($count>2)&&(strlen($word)>2)) {$out.='<span style="font-size: ' . $size . '%;"><acronym title="' . $word. ' ' .$count . ' times.">' . $word . '</acronym></span> ';}
}
return $out.='</p>' ;
}

see the Plugin simpleCloud
or the Plugin PM_Cloud
back to addons

Discussion

Viktor, 2011/04/24 11:53

At attempt to connect <? include(”./cmsimple/cloud.php”); ?> Doesn't work a theme in breakage!!!

Tillman Schuster, 2011/07/20 09:53

It wasn't meant to do that! Try the plugin. Till

fgddg, 2011/10/11 08:26

Does Total Loan amounts ease a unimportant tale? The pushing nose drains the economy without the mint. The triangle fears Total Loan amounts with a saint. A batch corrects Total Loan amounts. When will Total Loan amounts arrive inside the threshold?

http://www.addmy5.info

addons/cloud.txt · Last modified: 2009/12/16 20:05 by gerwin
Webdesign: NMuD chimeric.de = chi`s home Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0