使用过 chevereto 图床程序的朋友可能都有在自己的网站首页显示托管图片的数量的需求,而这个功能需要我们手动去实现,网上有很多这方面的教程,但大多都过于繁琐。本文分享一种比较简单通用的方法,供大家参考。
修改首页代码
修改 index.php 文件,位置:/chevereto/app/themes/Peafowl/views/index.php,找到下述代码:
<div class="home-buttons"> ...... </div>
在下面添加下述代码:
<p id="home-cover-msg"> <?php echo CHV\getSetting('homepage_paragraph_html') ?: _s('<span class=\'image-count\'>%s</span> images hosted', get_totals()['images'] > 999999 ? get_totals_display()['images'] : number_format(get_totals()['images'])); ?> </p>
修改后台代码
修改 route.index.php 文件,位置:/chevereto/app/routes/route.index.php,找到下述代码:
$handler::setVar('doctitle', CHV\Settings::get('website_doctitle')); $handler::setVar('pre_doctitle', CHV\Settings::get('website_name'));
在此后添加代码:
$handler::setVar('totals', CHV\Stat::getTotals());
通过以上两步即可实现。
本文已通过「原本」原创作品认证,未经作者授权请勿直接转载,负责将依法追究其法律责任。
如果认为本文对您有所帮助请赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏