怎样单独输出二级菜单导航?

讨论程序使用中的问题
回复
gdhzkk
帖子: 64
注册时间: 2016年 5月 30日 10:54
联系:

怎样单独输出二级菜单导航?

帖子 gdhzkk »

网上找到的是这个
<?php $this->widget('Widget_Metas_Category_List')->listCategories('wrapClass=widget-list'); ?>

这个代码是一级分类和子栏目都输出的,但我只想单独输出当前分类下的子栏目。
如:

导航分类样式 首页 新闻 图片 专题

子栏目样式(默认首页不显示的) 当页面在新闻分类下显示新闻的子菜单,当页面在图片分类下显示图片的子菜单

kfx
帖子: 50
注册时间: 2010年 9月 9日 07:51
联系:

Re: 怎样单独输出二级菜单导航?

帖子 kfx »

这个我要帮你顶下,因为好多人,都需要解决这个问题。你的描述让人糊涂,我替你: 首页显示所有父类,其中一个父母假设叫水果, 点击这个水果,进入水果父类下的所有文章列表页,然后在这个列表页上方,显示子类,如香蕉,樱桃………

是这个意思吧。 我也是同求。 唉。 喜欢简洁的te,可是简洁也是有代价的,硬币的两面呀……
刘国雄
帖子: 3
注册时间: 2014年 4月 29日 13:56

Re: 怎样单独输出二级菜单导航?

帖子 刘国雄 »

我也遇到了这个问题,在网上没查到解决方案,https://segmentfault.com/q/1010000005983090 这个是我贴出来的详细需求
Eager
帖子: 44
注册时间: 2011年 9月 23日 05:00
联系:

Re: 怎样单独输出二级菜单导航?

帖子 Eager »

编辑主题模板可实现,实例 ideager.com 中的作品浮动层就是二级菜单!
以下是源代码,把二级菜单绑定在slug为handmade页面导航菜单上

代码: 全选

<ul class="header-nav">
      <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
      <?php while($pages->next()): ?>
      <li>
        <a href="<?php $pages->permalink(); ?>" class="ajax-link<?php if($this->is('page', $pages->slug)): ?> current<?php endif; ?>"><?php $pages->title(); ?></a>
        <?php if($this->is($pages->slug == 'handmade')): ?>
          <?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
          <?php while($categorys->next()): ?>
          <?php if ($categorys->levels === 0): ?>
          <?php $children = $categorys->getAllChildren($categorys->mid); ?>
          <ul>
          <?php foreach ($children as $mid) { ?>
          <?php $child = $categorys->getCategory($mid); ?>
          <li><a href="<?php echo $child['permalink'] ?>" class="ajax-link<?php if($this->is('category', $mid)): ?> active<?php endif; ?>"><?php echo $child['name']; ?></a><span class="badge"><?php echo $child['count']; ?></span></li>
          <?php } ?>
          </ul>
          <?php endif; ?>
          <?php endwhile; ?>
        <?php endif; ?>
      </li>
      <?php endwhile; ?>
    </ul>
gdhzkk
帖子: 64
注册时间: 2016年 5月 30日 10:54
联系:

Re: 怎样单独输出二级菜单导航?

帖子 gdhzkk »

Eager 写了:编辑主题模板可实现,实例 ideager.com 中的作品浮动层就是二级菜单!
以下是源代码,把二级菜单绑定在slug为handmade页面导航菜单上

代码: 全选

<ul class="header-nav">
      <?php $this->widget('Widget_Contents_Page_List')->to($pages); ?>
      <?php while($pages->next()): ?>
      <li>
        <a href="<?php $pages->permalink(); ?>" class="ajax-link<?php if($this->is('page', $pages->slug)): ?> current<?php endif; ?>"><?php $pages->title(); ?></a>
        <?php if($this->is($pages->slug == 'handmade')): ?>
          <?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>
          <?php while($categorys->next()): ?>
          <?php if ($categorys->levels === 0): ?>
          <?php $children = $categorys->getAllChildren($categorys->mid); ?>
          <ul>
          <?php foreach ($children as $mid) { ?>
          <?php $child = $categorys->getCategory($mid); ?>
          <li><a href="<?php echo $child['permalink'] ?>" class="ajax-link<?php if($this->is('category', $mid)): ?> active<?php endif; ?>"><?php echo $child['name']; ?></a><span class="badge"><?php echo $child['count']; ?></span></li>
          <?php } ?>
          </ul>
          <?php endif; ?>
          <?php endwhile; ?>
        <?php endif; ?>
      </li>
      <?php endwhile; ?>
    </ul>



谢谢,因为有人回帖了系统也没有提示,所以我好久都没打开这个贴了,非常感谢你的回复
头像
ClayMore
帖子: 2483
注册时间: 2007年 11月 29日 02:55
来自: Sleeping Forest
联系:

Re: 怎样单独输出二级菜单导航?

帖子 ClayMore »

收藏备用


__________________

新版阿里百秀Alibaixiu主题 v11.1 For Typecho
http://xiu.160.me/
回复