mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-06-29 07:59:25 +02:00
FIX: Ensure tag cloud widget does not break when there are zero tags
This commit is contained in:
parent
96d8adebab
commit
515928b8e2
|
@ -90,11 +90,14 @@ class BlogTagsCloudWidget extends Widget
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize the tag counts from 1 to 10
|
// normalize the tag counts from 1 to 10
|
||||||
|
if ($maxTagCount) {
|
||||||
$tagfactor = 10 / $maxTagCount;
|
$tagfactor = 10 / $maxTagCount;
|
||||||
foreach ($tags->getIterator() as $tag) {
|
foreach ($tags->getIterator() as $tag) {
|
||||||
$normalized = round($tagfactor * ($tag->TagCount));
|
$normalized = round($tagfactor * ($tag->TagCount));
|
||||||
$tag->NormalizedTag = $normalized;
|
$tag->NormalizedTag = $normalized;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user