Vous devez ensuite créer un nouveau fichier, au même niveau que oxml.php, que nous appellerons 'tag_cloud.php' dans notre exemple.

Voici son contenu :

<style type="text/css">
#tagcloud {
        background-color: #EAEAEA;
        width: 600px;
        border: 1px solid #BFBFBF;
        padding: 10px;
        text-align: center;
        margin-top: 2px;
        margin-right: auto;
        margin-bottom: 0px;
        margin-left: auto;
        font-family: Arial, Helvetica, sans-serif;
        line-height: 22px;
}
#tagcloud a {
        text-decoration:none;
}
#tagcloud a:hover {
        text-decoration:none;
        background-color:#B3B3B3;
        color:#FFFFFF;
}
.tg-1 {
        color:#AA3406;
        font-size: 18px;
}
.tg-2 {
        color:#AA3406;
        font-size: 16px;
}
.tg-3 {
        font-size: 14px;
        color:#070089;
}
.tg-4 {
        font-size: 12px;
        color:#BF2470;
}
.tg-5 {
        font-size: 10px;
        color:#333333;
}
</style>
 
<?
/**
 * OXML - TAG CLOUD
 */
 
$dsn2 = new DB();
$sql2 = "SELECT `key`, `n` FROM `".DB_SEARCH_TOP."` WHERE `res` > '0' ORDER by rand() LIMIT 0,35";
$dsn2->query($sql2);
while ($result = $dsn2->next_record()) {
        $key = trim($result['key']);
        $tag_tab[$key] = $result['n'];
}
 
ksort($tag_tab);
$max = max($tag_tab);
 
$limit[0] = $max*20/100;
$limit[1] = $max*40/100;
$limit[2] = $max*60/100;
$limit[3] = $max*80/100;
 
foreach ($tag_tab as $key => $val){
 
        if($val > $limit[3]){
                $style = 1;
        } elseif($val > $limit[2]){
                $style = 2;
        } elseif($val > $limit[1]){
                $style = 3;
        } elseif($val > $limit[0]){
                $style = 4;
        } else {
                $style = 5;
        }
 
        $tag .= "<a href='" . perm_search($key) . "' class='tg-" . $style . "'>" . stripslashes($key) . "</a>&nbsp;&nbsp;\n";
}
echo '<div id="tagcloud">' . $tag . '</div>';
 
?>

Dans votre template, à l'endroit où vous souhaitez afficher le nuage de mots clés, placez ce code :

<?php include('tag_cloud.php'); ?>

Vous pouvez librement modifier la présentation du nuage de mots cléfs en modifiant le fichier tag_cloud.php.

oxml/addons/tag_cloud.txt · Dernière modification: 2009/09/23 10:56 par oxphp
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0