mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
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:
commit
84efcf126b
@ -90,12 +90,15 @@ class BlogTagsCloudWidget extends Widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normalize the tag counts from 1 to 10
|
// normalize the tag counts from 1 to 10
|
||||||
$tagfactor = 10 / $maxTagCount;
|
if ($maxTagCount) {
|
||||||
foreach ($tags->getIterator() as $tag) {
|
$tagfactor = 10 / $maxTagCount;
|
||||||
$normalized = round($tagfactor * ($tag->TagCount));
|
foreach ($tags->getIterator() as $tag) {
|
||||||
$tag->NormalizedTag = $normalized;
|
$normalized = round($tagfactor * ($tag->TagCount));
|
||||||
|
$tag->NormalizedTag = $normalized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user