Typecho的Joe主题新增cnzz统计

Typecho的Joe主题新增cnzz统计

ZJ
ZJ
2022-09-15 / 0 评论 / 27 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2022年09月15日,已超过586天没有更新,若内容或图片失效,请留言反馈。

Test

1.修改footer.php,新增代码,文件路径:usr/themes/Joe/public
第一段,在文件最上方添加
<?php 
    if(Helper::options()->CnzzType !== 'off') {
        $CnzzIdSave = Helper::options()->CnzzId;
        $CnzzTypeStyle = Helper::options()->CnzzType;
        $CnzzTypeStyle = str_replace("CnzzId", $CnzzIdSave, $CnzzTypeStyle);
    }
?>

第二段添加在网站运行时间前面
<div class="item" style="margin: 10px; <?php if(Helper::options()->CnzzType == 'off') echo 'display:none;'  ?>">
    <span id='cnzz_stat_icon_<?php Helper::options()->CnzzType ?>'></span><script src='<?php echo $CnzzTypeStyle ?>' type='text/javascript'></script>
</div>

Test

2.修改functions.php文件,新增代码,文件路径:/usr/themes/Joe
$CnzzId = new Typecho_Widget_Helper_Form_Element_Text(
    'CnzzId',
    NULL,
    NULL,
    'cnzz站点ID',
    '介绍:填写此处用于展示cnzz统计,该地址进行申请 https://www.umeng.com/web'
);
$CnzzId->setAttribute('class', 'joe_content joe_custom');// 如果后台无法展示设置,将joe_custom替换为joe_other
$form->addInput($CnzzId->multiMode());

$CnzzType = new Typecho_Widget_Helper_Form_Element_Select(
    'CnzzType',
    array(
        'off' => '关闭(默认)',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&web_id=CnzzId' => '文字形式',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic' => '图片样式1',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic1' => '图片样式2',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&show=pic2' => '图片样式3',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&online=2' => '在线人数',
        'https://s4.cnzz.com/z_stat.php?id=CnzzId&online=1&show=line' => '横排数据显示',
    ),
    'off',
    '选择cnzz样式',
    '介绍:开启时请填写cnzz站点ID'
);
$CnzzType->setAttribute('class', 'joe_content joe_custom');// 如果后台无法展示设置,将joe_custom替换为joe_other
$form->addInput($CnzzType->multiMode());

Test

本文共 140 个字数,平均阅读时长 ≈ 1分钟
1

评论 (0)

取消