當(dāng)前位置:
首頁 >
typecho导航栏调用分类目录代码
發(fā)布時間:2023/11/21
56
生活家
生活随笔
收集整理的這篇文章主要介紹了
typecho导航栏调用分类目录代码
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
typecho的默認(rèn)主題導(dǎo)航菜單部分調(diào)用的是獨(dú)立頁面,而我們搭建網(wǎng)站一般是把分類目錄顯示在導(dǎo)航欄,或者把分類目錄和獨(dú)立頁面一起顯示在導(dǎo)航欄,這樣便于訪客瀏覽網(wǎng)站目錄。下面博客吧分享typecho分類目錄顯示在導(dǎo)航欄的代碼。
只顯示分類目錄
在主題的header.php文件中找到代碼:
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while($pages->next()): ?>
<a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php%20$pages->permalink();%20?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>
修改為以下代碼:
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while($category->next()): ?>
<li><a<?php if($this->is('category', $category->slug)): ?> class="current"<?php endif; ?> href="<?php%20$category->permalink();%20?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a></li>
<?php endwhile; }?>
分類目錄和獨(dú)立頁面都顯示
在主題的header.php文件中找到代碼:
<?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
<?php while($pages->next()): ?>
<a<?php if($this->is('page', $pages->slug)): ?> class="current"<?php endif; ?> href="<?php%20$pages->permalink();%20?>" title="<?php $pages->title(); ?>"><?php $pages->title(); ?></a>
<?php endwhile; ?>
在該代碼上面添加代碼:
<?php $this->widget('Widget_Metas_Category_List')->to($category); ?>
<?php while($category->next()): ?>
<li><a<?php if($this->is('category', $category->slug)): ?> class="current"<?php endif; ?> href="<?php%20$category->permalink();%20?>" title="<?php $category->name(); ?>"><?php $category->name(); ?></a></li>
<?php endwhile; }?>
本文轉(zhuǎn)自:博客吧https://www.boke8.net/typecho-navigation-display-categories.html
總結(jié)
以上是生活随笔為你收集整理的typecho导航栏调用分类目录代码的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: thinkphp在php5.5版本以上”
- 下一篇: 淘宝店铺基本运营方法大全