所以说jquery是个好东西

只要你载入了jquery,能用jqyery解决的问题就不要使用其他办法了
比如:

<script>
//锚点链接添加平滑滚动效果
$(document).ready(function() {
  $("#g7-toc a.nav-link").click(function() {
    $("html, body").animate({
      scrollTop: $($(this).attr("href")).offset().top + "px"
    }, {
      duration: 500,
      easing: "swing"
    });
    return false;
  });
});
</script>

一些主题设计网站元素

http://keydesign-themes.com/incubator/ *****
http://keydesign-themes.com/incubator/documentation/
http://keydesign-themes.com/incubator/creative-agency/

https://flarefile.com/d/Themeforest-17028809-incubator-wordpress-startup-business-Theme-cmsdudeOrg.zip
https://cmsdude.org/wordpress-themes/themeforest-incubator-download-wordpress-startup-business-theme/
http://themenectar.com/demo/salient-promo/
http://themes.quemalabs.com/vito/
http://bridge58.qodeinteractive.com/

左侧分类样式代码

什么都不说,先看代码:

    <nav class="collapse g7-sidenav" id="g7-cat-nav">    
        <?php
        $this->widget('Widget_Metas_Category_List')->to($categories);
        if($categories->have()){
            while($categories->next()){?>
            <div class="g7-sidenav-item <?php if($categories->parent == 0 ): ?>cat-parent<?php else: ?>cat-child<?php endif;?> <?php if($this->category == $categories->slug): ?> active<?php endif; ?>" id="<?php $categories->slug(); ?>">
                <a class="g7-sidenav-link d-flex" href="<?php $categories->permalink(); ?>">
                <?php if($this->category == $categories->slug): ?>
                <svg class="px-1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
                <?php else: ?>
                <svg  class="px-1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
                <?php endif; ?><?php $categories->name(); ?></a>
                <?php
                if ($categories->count == 0) { $pagesize = 0;} else{ $pagesize = 25;};
                $this->widget('Widget_Archive@'.$categories->name, 'pageSize='.$pagesize.'&type=category', 'mid='.$categories->mid)->to($categoryposts);
                    if($categoryposts->have()){ ?>
                        <ul class="nav g7-sidenav-list">
                        <?php while ($categoryposts->next()) { ?>
                        <li <?php if($this->slug == $categoryposts->slug): ?> class="active g7-sidenav-list-active"<?php endif; ?>><a href="<?php $categoryposts->permalink(); ?>"><?php $categoryposts->title(); ?></a></li>
                        <?php
                        }
                        echo '</ul>';
                    }
                        echo '</div>';
            }
        }else{
            echo '无分类';
        }
        ?>
    </nav>

最主要的是14行的代码,通过$categories->count判断目录下是否有直接文章,没有就不显示,有的话就显示25个,不然文章多了就受不了了

2017.11.24更新

通过一个while(){}和while(): endwhile的原因,发现自己写的这段代码真特么的乱,自己想修改都看的累死,所以,改了。

<nav class="collapse g7-sidenav" id="g7-cat-nav">    
    <?php  $this->widget('Widget_Metas_Category_List')->to($categories); ?>
    <?php if($categories->have()): ?>
        <?php while($categories->next()):?>
            <div class="g7-sidenav-item <?php if($categories->parent == 0 ): ?>cat-parent<?php else: ?>cat-child<?php endif;?> <?php if($this->category == $categories->slug): ?> active<?php endif; ?>" id="<?php $categories->slug(); ?>">
                <a class="g7-sidenav-link d-flex" href="<?php $categories->permalink(); ?>">
                <?php if($this->category == $categories->slug): ?>
                    <svg class="px-1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg>
                <?php else: ?>
                    <svg  class="px-1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-right"><polyline points="9 18 15 12 9 6"></polyline></svg>
                <?php endif; ?>
                <?php $categories->name(); ?>
                </a>
            <?php if ($categories->count == 0) : $pagesize = 0; else: $pagesize = 25; endif; ?>
            <?php $this->widget('Widget_Archive@'.$categories->name, 'pageSize='.$pagesize.'&type=category', 'mid='.$categories->mid)->to($categoryposts); ?>
                <?php if($categoryposts->have()) : ?>
                    <ul class="nav g7-sidenav-list">
                        <?php while ($categoryposts->next()) : ?>
                        <li <?php if($this->slug == $categoryposts->slug): ?> class="active g7-sidenav-list-active"<?php endif; ?>><a href="<?php $categoryposts->permalink(); ?>"><?php $categoryposts->title(); ?></a></li>
                        <?php endwhile; ?>
                    </ul>
                <?php endif; ?>
            </div>
        <?php endwhile; ?>
    <?php else : ?>
        <?php _e('无分类'); ?>
    <?php endif; ?>
</nav>

扫一扫,访问移动端

高凯的个人主页
I am alone on my life's Journey up to now, and the future.

推荐 / Digest

热点 / Hot

评论 / Comments

  • Gaobukai: <img class="profile-avat...
  • nico: 头像改为以下函数,还是不起作用。src="<?php av...
  • nico: 现在主题是用下面代码实现src="<?php tx($ne...
  • nico: 博主,我想请教一下。在主题里面怎么调用上传头像。后天正常显示是上...
  • Gaobukai: 这个点赞的按钮为什么总报错呢?
  • Gaobukai: 既然能调用0号图片就能调用随机图片<?php rand(0...

标签 / Tags

推广 / Ads