管理站点的时候,发现有一个标签“指南”下的页面有一堆乱码,但其他标签都是正常显示面包屑导航的。隐约记得曾经尝试过在某个标签下打印标签数组数据,估计是自己忘记把测试代码删除掉了。因为出问题的位置位于面包屑导航部分,于是检查了一下面包屑导航的代码,确实有一个指向“指南”标签的判断。代码如下:
<?php if($this->is('index')):?><!-- 页面为首页时 -->
<?php elseif ($this->is('post')): ?><!-- 页面为文章单页时 -->
<div id="aug-bread" class="aug-container">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<a class="headbread" href="<?php $this->options->siteUrl(); ?>">首页</a><span>></span><?php $this->category(); ?><span>></span><?php $this->title(); ?>
</div>
<?php
elseif ($this->is('tag','guide')):
var_dump($this->tags);
?>
<?php else: ?><!-- 页面为其他页时 -->
<div id="aug-bread" class="aug-container">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<a class="headbread" href="<?php $this->options->siteUrl(); ?>">首页</a><span>></span><?php $this->archiveTitle(' » ','',''); ?>
</div>
<?php endif; ?>
删除之前在博客上随手做个记录,避免以后需要的时候想不起来:
<?php
//判断标签页可以直接用如下的命令
if ($this->is('tag')):
var_dump($this->tags);
endif;
//而判断具体某一个标签,只需要增加一个参数,指明标签的别名就可以了
if ($this->is('tag','guide')):
var_dump($this->tags);
endif;
?>