The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 861 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function: tagCloud
#1
Simple function to extract all the meta tags from pages and display a Tag Cloud.

You'll need to change the link tags depending on what you want to do with the link, either through onlick or normal links.

Might be of use to someone....

Mike.

This is revision 1.1 of the code.

Code:
function tagCloud(){
    $minFont=14;            // change to min font size
    $maxFont=20;            // change to max font size
    $tags  = array();
    $cloud = array();
    // Grab the tags from the database
    
    $path = "data/pages";
    $dir_handle = @opendir($path) or die("Unable to open $path");
    $filenames = array();
    while ($filename = readdir($dir_handle)) {
        $filenames[] = $filename;
    }
    
    $count=0;
    $value="";
    if (count($filenames) != 0) {
        foreach ($filenames as $file) {
            if ($file == "." || $file == ".." || is_dir("data/pages/".$file) || $file == ".htaccess"  ) {
                // not a page data file
            } else {
                $thisfile = @file_get_contents('data/pages/'.$file);
                $data = simplexml_load_string($thisfile);
                if ($data->private != 'Y') {
                    $metaData = $data->meta;
                    $db = explode(' ', $metaData);    
                    while(list($key, $value) = each($db)){
                           @$tags[(string)$value] += 1;
                    }
                      $count++;
                }
            }
        }
    }
        
    // Get totals to use for font size    
    $min = min(array_values($tags));
    $max = max(array_values($tags));
    $fix = ($max - $min == 0) ? 1 : $max - $min;
    // Display the tags
    foreach ($tags as $tag => $count) {
        $size = $minFont + ($count - $min) * ($maxFont - $minFont) / $fix;
        $jsLink=" onclick=\"searchTag('".$tag."');\" ";  // change this if
        $normalLink='#';                    // change if you want to use normal links
        $cloud[] = '<a  style="font-size:'. floor($size) .'px" class="cloud" href="'.$normalLink.'" title=" '. ucfirst($tag) .' ('. $count .')"  '.$jsLink.' >'. htmlspecialchars(stripslashes(ucfirst($tag))) . '</a>';
    }
    $shown = join("\n", $cloud) . "\n";
    echo  $shown;
}
My Github Repos: Github
Website: DigiMute
Reply


Messages In This Thread
Function: tagCloud - by n00dles101 - 2009-11-20, 21:04:58
Function: tagCloud - by Zegnåt - 2009-11-20, 22:03:01
Function: tagCloud - by n00dles101 - 2009-11-20, 23:45:04
Function: tagCloud - by ccagle8 - 2009-12-09, 08:13:02
Function: tagCloud - by Jamz - 2009-12-15, 08:52:39
Function: tagCloud - by n00dles101 - 2009-12-15, 19:50:43
Function: tagCloud - by Zegnåt - 2009-12-15, 19:56:06
Function: tagCloud - by internet54 - 2009-12-16, 02:53:14
Function: tagCloud - by Zegnåt - 2009-12-16, 03:53:18
Function: tagCloud - by n00dles101 - 2009-12-16, 05:04:44
Function: tagCloud - by homershines - 2010-04-21, 14:04:28
Function: tagCloud - by Zegnåt - 2010-04-23, 00:57:21
Function: tagCloud - by homershines - 2010-04-23, 02:55:17
Function: tagCloud - by Zegnåt - 2010-04-23, 07:07:39
Function: tagCloud - by kirillaristov - 2010-04-24, 01:11:12
Function: tagCloud - by homershines - 2010-04-24, 04:53:54
Function: tagCloud - by n00dles101 - 2010-04-24, 05:58:51
Function: tagCloud - by homershines - 2010-04-24, 22:31:46
Function: tagCloud - by banter - 2010-04-27, 18:30:05
Function: tagCloud - by n00dles101 - 2010-04-27, 18:59:05
Function: tagCloud - by homershines - 2010-04-29, 00:25:26



Users browsing this thread: 1 Guest(s)