Voodoo\Core\Helpers::createTagCloud PHP Method

createTagCloud() public method

To create a tag cloud based on the tags provided
public createTagCloud ( array $Tags, string $Link = "", INT $cloud_spread, $sort = "count", string $title = "%tag%", boolean $sizeTags = false ) : String
$Tags array - array($tagName=>$tagCount)
$Link string - Link to connect to the tags
$cloud_spread INT - max tags to show
$sort
$title string - the title to enter in the link. Can be formatted with %tag% | %count% to add the tag and count respectively in the a href title
$sizeTags boolean - to allow multiple size of fonts
return String LI
    public function createTagCloud(array $Tags, $Link = "", $cloud_spread = 0, $sort = "count", $title = "%tag%", $sizeTags = false)
    {
        // Count tags
        $totalTags = count($Tags);
        // The base size of the font-size
        $fontSize_base = 13;
        // the font size ratio, the higher the bigger the font-size will be
        $fontSize_ratio = 1.5;
        // Sorting the tags
        if ($sort == "tag") {
            ksort($Tags);
        } else {
            arsort($Tags);
        }
        // Creating the list
        foreach ($Tags as $tagName => $tagCount) {
            $fontSize = round($tagCount * 100 / $totalTags) * $fontSize_ratio + $fontSize_base;
            $urlKey = urlencode($tagName);
            $urlTitle = str_replace(array("%tag%", "%count%"), array($tagName, $tagCount), $title);
            $styleTag = $sizeTags ? "style=\"font-size:{$fontSize}px;\"" : "";
            $cloud .= "<li {$styleTag} ><a href=\"{$Link}{$urlKey}\" title=\"{$urlTitle}\">{$tagName}</a></li>\n";
            $count++;
            // To count for cloud spread
            if ($cloud_spread && $count >= $cloud_spread) {
                break;
            }
        }
        return $cloud;
    }