Merge pull request #381 from gordonbanderson/377-no-tags-break

FIX: Ensure tag cloud widget does not break when there are zero tags
This commit is contained in:
Daniel Hensby 2016-02-24 18:09:54 +00:00
commit 84efcf126b

View File

@ -90,12 +90,15 @@ class BlogTagsCloudWidget extends Widget
}
// normalize the tag counts from 1 to 10
$tagfactor = 10 / $maxTagCount;
foreach ($tags->getIterator() as $tag) {
$normalized = round($tagfactor * ($tag->TagCount));
$tag->NormalizedTag = $normalized;
if ($maxTagCount) {
$tagfactor = 10 / $maxTagCount;
foreach ($tags->getIterator() as $tag) {
$normalized = round($tagfactor * ($tag->TagCount));
$tag->NormalizedTag = $normalized;
}
}
return $tags;
}