大前段的DUX还是一样的流行,可是根据作者的习惯,依旧一部分功能与购买的正式版有所不同,而且询问作者后给予的回复就是这个本来就没有,不过也无妨,该主题的功能本来就已经很强大了,只是有点美中不足而已,那么既然有首页公告那就有站长推荐和联系我们,代码差不多都一样,下面就看看本站是怎么实现的吧。
该功能仅需要修改dux主题的两个文件,分别是
dux\options.php(主题后台配置选项的设置,为了让站长推荐和联系我们具有可配置性)
dux\modules\mo_notice.php(现实站长推荐和联系我们显示的地方)。
options.php中搜索首页公告,在其整个配置项下方添加如下代码:
$options[] = array( 'name' => __('首页推荐', 'haoui'), 'type' => 'heading' ); $options[] = array( 'name' => __('显示推荐模块', 'haoui'), 'id' => 'site_recom_s', 'std' => true, 'desc' => __('显示推荐模块', 'haoui'), 'type' => 'checkbox'); $options[] = array( 'name' => __('显示标题', 'haoui'), 'id' => 'site_recom_title', 'desc' => '建议4字内,默认:站长推荐', 'std' => '站长推荐', 'type' => 'text'); $options[] = array( 'name' => __('推荐代码', 'haoui'), 'id' => 'site_recom_text', 'std' => '<h2>站长推荐:DigitalOcean服务器<br><strong>$5/月</strong></h2><a class="btn btn-primary" href="http://blog.liyang.io">点击查看优惠</a>', 'desc' => __('建议20字内,可以使用html标签', 'haoui'), 'type' => 'textarea'); // ====================================================================================================================== $options[] = array( 'name' => __('联系模块', 'haoui'), 'type' => 'heading' ); $options[] = array( 'name' => __('是否显示联系模块', 'haoui'), 'id' => 'site_contact_s', 'std' => true, 'desc' => __('显示联系模块', 'haoui'), 'type' => 'checkbox'); $options[] = array( 'name' => __('显示标题', 'haoui'), 'id' => 'site_contact_title', 'desc' => '四个汉字以内,默认:联系我们', 'std' => '联系我们', 'type' => 'text'); $options[] = array( 'name' => __('联系方式代码', 'haoui'), 'id' => 'site_contact_text', 'std' => '<h2>如无特殊,每天早晚2次邮件回复 <br>admin@liyang.io</h2>', 'desc' => __('建议20字内,可以使用html标签', 'haoui'), 'type' => 'textarea');
接着修改mo_notice.php,在
$s_user = _hui('user_page_s') && _hui('user_on_notice_s');
下方添加如下两行代码:
$s_recom = _hui("site_recom_s"); $s_contact = _hui("site_contact_s") && _hui("user_on_notice_s");
在
<?php if( $s_user ){ ?><li<?php echo ($s_user && !$s_notice ) ? ' class="active"' : '' ?>>会员中心</li><?php } ?>
下方添加如下两行代码:
<?php if( $s_recom ){ ?><li<?php echo ($s_recom && !$s_user && !$s_notice ) ? ' class="active"' : '' ?>><?php echo _hui('site_recom_title') ? _hui('site_recom_title') : '站长推荐' ?></li><?php } ?> <?php if( $s_contact ){ ?><li<?php echo ( $s_contact && !$s_recom && !$s_user && !$s_notice ) ? ' class="active"' : '' ?>><?php echo _hui('site_contact_title') ? _hui('site_contact_title') : '联系我们' ?></li><?php } ?>
在倒数第一个<?php } ?>的下面添加如下代码:
<?php if( $s_recom ){ ?> <li class="item item-03<?php echo ($s_recom && !$s_user && !$s_notice) ? ' active' : '' ?>"> <?php echo _hui('site_recom_text') ?> </li> <?php } ?> <?php if( $s_contact ){ ?> <li class="item item-04<?php echo ($s_contact && !$s_recom && !$s_user && !$s_notice) ? ' active' : '' ?>"> <?php echo _hui('site_contact_text') ?> </li> <?php } ?>
这样就可以显示站长推荐和联系我们的两个模块了,美中不足的是必须开启会员中心选项才可以现实。
最后大前端的这个主题真心不错,还希望大家能够多支持下,我自己也是付费用户。