首页 » 日记 » 正文内容
5个月前 寻梦xunm 203 日记

请输入图片描述

把下面的代码添加到“functions.php”文件中

 $fenlei = new \Typecho\Widget\Helper\Form\Element\Textarea(
    'fenlei',
    null,
    null,
    _t('分类图标'),
    _t('可以通过这里自定义分类图标,多个请用|进行分隔。列如:http://xx.xx/xx.png|http://xx.xx/xx.png')
);

$form->addInput($fenlei);

模板中分类图标调用代码如下

<?php $fenleiimg = explode('|',rtrim($this->options->fenlei,'|')); ?>
<?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
<?php $i = 0; while($categorys->next()): ?>
    <a href="<?php $categorys->permalink(); ?>" title="<?php $categorys->name(); ?>">
        <img src="<?php echo $fenleiimg[$i]; ?>">
        <p><?php $categorys->name(); ?></p>
    </a>
<?php $i++; endwhile; ?>

0 赞 or 打赏
喜欢就打赏一点
微信 支付宝
已有0 条评论,0 个点赞
隐私

Q Q:1340326824

vipshiyi@qq.com

QQ群:422720328

生活所迫,再见了苦逼的BUG们,以后有缘在会吧。