在Chevereto V4 首页显示图片托管数量,今天为大家分享一下 Chevereto V4 首页显示图片托管数量的实现方法。

1. 修改后台代码

 

修改 index.php 文件,位置:/chevereto/app/legacy/routes/index.php,修改以下两处:

 

第一处: 找到下述代码:

use Chevereto\Legacy\Classes\Settings;


在此后添加代码:

use Chevereto\Legacy\Classes\Stat;

第二处: 找到下述代码:

$handler::setVar('doctitle', _s(Settings::get('website_doctitle'));
$handler::setVar('pre_doctitle', _s(Settings::get('website_name'));

在此后添加代码:

$handler::setVar('totals', Stat::getTotals());

2. 修改首页代码

修改 index.php 文件,位置:/chevereto/content/legacy/themes/Peafowl/views/index.php,修改以下一处:

找到下述代码:

<div class="home-buttons">
    <?php echo Handler::var('homepage_cta'); ?>
</div>

添加以下内容:

<p id="home-cover-msg">
    已托管 <span class="image-count" style="color:#27AE61;"><?php echo (number_format((float) Handler::var('totals')['images'])); ?></span> 张图片
</p>

到这一步就大功告成了。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。