zoukankan      html  css  js  c++  java
  • phpcms导航菜单的写法

    PHP打印方法:
    {php print_r(变量);}
    <?php print_r(变量);?>
    1.
    <div class="webnav">
                {pc:get sql="select catname,url from v9_category order by listorder ASC" }
                    <ul class="clearfix">
                        <!--<li><a href="{siteurl($siteid)}">首页</a></li>-->
                        {loop $data $r}
                        <li><a href="{$r[url]}">{$r[catname]}</a></li>
                    {/loop}    
                    </ul>
                {/pc}
                {php echo runhook('glogal_menu')}
            </div>

    加粗的写法:从栏目表查出catname 和 url字段值 按照listorder 正序排列

     {pc:get sql="select catname,url from v9_category order by listorder ASC" }  可以改写成
     {pc:get sql="select*from v9_category order by listorder ASC" }
     
    2.导航选中状态:
    {if $catid == $r['catid']}class="current"{/if}

    例如:

    <div class="webnav">
                {pc:get sql="select * from v9_category order by listorder ASC" }
                    <ul class="clearfix">
                        {if $catid}
                            <li><a href="{siteurl($siteid)}">首页</a></li>
                        {else}
                            <li class="current"><a href="{siteurl($siteid)}">首页</a></li>
                        {/if}
                        {loop $data $r}
                        <li {if $catid==$r['catid']}class="current"{/if}><a href="{$r[url]}">{$r[catname]}</a></li>
                        {/loop}
                    </ul>
                {/pc}
    
                {php echo runhook('glogal_menu')}
            </div>

    当然首页那也可以这样:

    <li {if empty($catid)}class="current"{/if}><a href="{siteurl($siteid)}">首页</a></li>

    $catid //当前栏目ID
    $r['catid'] //循环出来的

     
  • 相关阅读:
    scrapy-redis使用以及剖析
    完全理解 Python 迭代对象、迭代器、生成器
    Python操作 RabbitMQ、Redis、Memcache、SQLAlchemy
    HTTP状态码
    Py西游攻关之RabbitMQ、Memcache、Redis
    Django contenttypes 应用
    cookie和session 以及Django中应用
    RESTful规范
    rest_framework框架的认识
    vue 总结
  • 原文地址:https://www.cnblogs.com/moqiutao/p/7116729.html
Copyright © 2011-2022 走看看