archive 里的is函数写的太乱了,一点可读性都没有

Bug,需求以及想法
回复
hbczxjq
帖子: 2
注册时间: 2010年 3月 13日 13:04

archive 里的is函数写的太乱了,一点可读性都没有

帖子 hbczxjq »

页面类型太少 至少应该有
index
post
page
category
archive
search
404

方便在header.php 里面用is函数判断来输出不同的标题
头像
ClayMore
帖子: 2483
注册时间: 2007年 11月 29日 02:55
来自: Sleeping Forest
联系:

Re: archive 里的is函数写的太乱了,一点可读性都没有

帖子 ClayMore »

代码: 全选

<?php if($this->is('search')): ?>
   <div class="boxcaption"><h3><?php _e('Search Results'); ?></h3></div>
   <div class="box"><?php _e('Keyword: ‘'); $this->archiveTitle('','',''); _e('’'); ?></div>

<?php else : ?>
   <div class="boxcaption"><h3><?php _e('Archive'); ?></h3></div>
   <div class="box">
      <?php
      // If this is a category archive
      if ($this->is('category')) {
         _e('Archive for the ‘'); $this->archiveTitle('','',''); _e('’ Category');
      // If this is a tag archive
      } elseif ($this->is('tag')) {
         _e('Posts Tagged ‘'); $this->archiveTitle('','',''); _e('’');
      // If this is a daily archive
      } elseif ($this->is('date')) {
         _e('Archive for'); $this->archiveTitle('-',' ','');
      // If this is an author archive
      } elseif ($this->is('author')) {
         _e('Author Archive');
      }
      ?>
   </div>
<?php endif; ?
头像
joyqi
帖子: 422
注册时间: 2007年 7月 24日 19:43
联系:

Re: archive 里的is函数写的太乱了,一点可读性都没有

帖子 joyqi »

你说的这些判断都支持,请试一下
至于实现方法就不具体解释了
头像
zyzzc
帖子: 648
注册时间: 2009年 9月 25日 20:11
联系:

Re: archive 里的is函数写的太乱了,一点可读性都没有

帖子 zyzzc »

都支持的,官方博客里有一篇专门说明的文章你找下
回复