Limit tagcloud

Allowing to set the tagcloud number
This commit is contained in:
danpros 2022-02-05 13:54:58 +07:00
commit e702617cc4
21 changed files with 234 additions and 2 deletions

View file

@ -81,6 +81,9 @@ recent.count = "5"
; Popular posts
popular.count = "5"
; Tagcloud
tagcloud.count = "40"
; Teaser type: set "trimmed" or "full".
teaser.type = "full"

View file

@ -1 +1 @@
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","views.root","views.layout"]
["site.url","timezone","date.format","language","blog.title","blog.tagline","blog.description","blog.copyright","permalink.type","static.frontpage","blog.enable","social.twitter","social.facebook","breadcrumb.home","comment.system","fb.appid","fb.num","fb.color","disqus.shortname","google.wmt.id","google.analytics.id","google.gtag.id","google.reCaptcha","google.reCaptcha.public","google.reCaptcha.private","posts.perpage","category.perpage","tag.perpage","archive.perpage","search.perpage","profile.perpage","type.perpage","json.count","category.info","related.count","recent.count","popular.count","tagcloud.count","teaser.type","read.more","teaser.char","description.char","rss.count","rss.char","views.counter","sitemap.priority.base","sitemap.priority.post","sitemap.priority.static","sitemap.priority.category","sitemap.priority.tag","sitemap.priority.archiveDay","sitemap.priority.archiveMonth","sitemap.priority.archiveYear","sitemap.priority.author","sitemap.priority.type","prerelease","cache.expiration","cache.off","generation.time","cache.timestamp","views.root","views.layout"]

View file

@ -258,3 +258,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Beiträge von"
Pages="Seiten"
Menu="Menüs"
Popular="Zugriffe"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -268,3 +268,5 @@ Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = TagCloud at most

View file

@ -255,3 +255,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Halaman"
Menu="Menu"
Popular="Populer"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -257,3 +257,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -269,3 +269,5 @@ Author_Description="Еще один пользователь HTMLy"
;404-search
Search_results_not_found="По вашему запросу ничего не найдено!"
No_search_results="Безрезультатно"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -274,3 +274,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -256,3 +256,17 @@ Posts_by="Posts by"
Pages="Pages"
Menu="Menu"
Popular="Popular"
;Errors
User_Error="User field is required"
Pass_Error="Password field is required"
Token_Error="CSRF Token not correct"
Captcha_Error="reCaptcha not correct"
Invalid_Error="ERROR: Invalid username or password"
;Profile
Post_by_author="Posts by this author"
Author_Description="Just another HTMLy user"
;404-search
Search_results_not_found="Search results not found!"
No_search_results="No search results"
;TagCloud
Tagcloud_widget_at_most = "TagCloud at most"

View file

@ -51,6 +51,12 @@
<input type="number" name="-config-popular.count" class="form-control" id="popular.count" value="<?php echo config('popular.count');?>">
</div>
</div>
<div class="form-group row">
<label for="tagcloud.count" class="col-sm-2 col-form-label"><?php echo i18n('Tagcloud_widget_at_most');?></label>
<div class="col-sm-10">
<input type="number" name="-config-tagcloud.count" class="form-control" id="tagcloud.count" value="<?php echo config('tagcloud.count');?>">
</div>
</div>
<br>
<h4><?php echo i18n('Comments');?></h4>
<hr>

View file

@ -1459,6 +1459,11 @@ function tag_cloud($custom = null)
$posts = get_post_unsorted();
$tags = array();
$tagcloud_count = config('tagcloud.count');
if(empty($tagcloud_count)) {
$tagcloud_count = 40;
}
if (!empty($posts)) {
if (!file_exists($filename)) {
@ -1497,7 +1502,11 @@ function tag_cloud($custom = null)
// this is the increase per tag quantity (times used)
$step = ($max_size - $min_size)/($spread);
foreach ($tag_collection as $tag => $count) {
arsort($tag_collection);
$sliced_tags = array_slice($tag_collection, 0, $tagcloud_count, true);
ksort($sliced_tags);
foreach ($sliced_tags as $tag => $count) {
$size = $min_size + (($count - $min_qty) * $step);
echo ' <a class="tag-cloud-link" href="'. site_url(). 'tag/'. $tag .'" style="font-size:'. $size .'pt;">'.tag_i18n($tag).'</a> ';
}