上上上上期给大家写了个侧边栏公告,但有个 缺点
,后台编辑公告栏无文字时不会隐藏,这样很不美观
修复教程开始
1.将下列代码放入主题目录的functions.php
文件里
// 侧边栏公告开关
$NoticeSwitch = new Typecho_Widget_Helper_Form_Element_Select(
'NoticeSwitch',
array(
'off' => '关闭(默认)',
'on' => '开启'
),
'off',
'是否开启侧边栏公告模块 - PC',
'介绍:用于控制是否显示公告'
);
$NoticeSwitch->setAttribute('class', 'joe_content joe_other');
$form->addInput($NoticeSwitch->multiMode());
2.再将下列代码放入主题目录的aside.php
文件里
<?php if ($this->options->NoticeSwitch === 'on') : ?>
包裹住你要隐藏的侧边栏模块的代码区域
<?php endif; ?>
懒人专用 把下面代码替换 3个方框
里的代码即可
<?php if ($this->options->NoticeSwitch === 'on') : ?>
<section class="joe_aside__item hot">
<div class="joe_aside__item-title">
<svg t="1703481319577" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1547" width="200" height="200"><path d="M770.9 161.9H648.4v-30.4c0-17.4-14.3-31.7-31.7-31.7h-1.8c-17.4 0-31.7 14.3-31.7 31.7v30.4H414.8v-30.4c0-17.4-14.3-31.7-31.7-31.7h-1.8c-17.4 0-31.7 14.3-31.7 31.7v30.4H227.2c-36.6 0-66.3 29.7-66.3 66.3V886c0 36.6 29.7 66.3 66.3 66.3h543.7c36.6 0 66.3-29.7 66.3-66.3V228.2c0-36.6-29.8-66.3-66.3-66.3z m-421.2 65.4v18.3c0 17.4 14.2 31.7 31.7 31.7h1.8c17.4 0 31.7-14.3 31.7-31.7v-18.1l168.4 0.3v17.8c0 17.4 14.2 31.7 31.7 31.7h1.8c17.4 0 31.7-14.3 31.7-31.7V228l123.6 0.3v112.4H227l0.2-113.5 122.5 0.1z m421.2 659.8L226 886l0.8-480.2H772V886c0 0.6-0.5 1.1-1.1 1.1z" fill="#4A5FE2" p-id="1548"></path><path d="M630.7 532.7H367.3c-17.9 0-32.6 14.7-32.6 32.6s14.7 32.6 32.6 32.6h263.4c17.9 0 32.6-14.7 32.6-32.6s-14.7-32.6-32.6-32.6zM630.7 654.9H367.3c-17.9 0-32.6 14.7-32.6 32.6 0 17.9 14.7 32.6 32.6 32.6h263.4c17.9 0 32.6-14.7 32.6-32.6 0-17.9-14.7-32.6-32.6-32.6z" fill="#A1AFFF" p-id="1549"></path></svg>
<span class="text">公告</span>
</div>
<?php $this->options->Notice() ?>
</section>
教程真详细,有帮助到
谢谢夸奖