yourphp模板技巧

1、取第2到第5条
<YP:list order="id desc" catid="1" limit="1,4"
>
      <li {if $i<=2 }class="first_li"{else}class="others_li"{/if}>
           <a href="http://gaoke0820.blog.163.com/blog/{$r.url}" class="fl">+ {$r.title|str_cut=###,30,''}</a>
           <span class="fr ffas f10">[{$r.createtime|toDate=###,'Y-m-d'}]</span>
     </li>
</YP:list>
2、多层导航
<ul class="lsn fl ffws f12 nav_main">
        <YP:subcat  catid="5">
            <li {if 1==$r['id']}style="margin-left:0"{/if} class="nav_main_li">
                  <a  class="nav_main_a">{$r.catname}</a>
                  <div class="nav_sub">
                        <YP:subcat  catid="$r[id]" id="vo">
                             <div class="fl nav_sub_list first_list">
                                    <h2><img src="http://gaoke0820.blog.163.com/blog/{$vo.image}" width="33" class="fl"><a href="http://gaoke0820.blog.163.com/blog/{$vo.url}" class="fl lh30 ml5 f14 ffws">{$vo.catname}</a><div class="cb"></div></h2>
                                    {if $vo['child']}                                
                                       <ul class="lsn mt12">
                                            <YP:subcat  catid="$vo[id]" id="res">
                                                 <li><a href="http://gaoke0820.blog.163.com/blog/{$res.url}">{$res.catname}</a></li>
                                            </YP:subcat>  
                                       </ul>
                                   {/if}
                             </div>
                     </YP:subcat>
                </div>
           </li>
        </YP:subcat>
</ul>

3、上级目录名称和上级目录的子目录

上级目录名称:{$Categorys[$parentid]['catname']} 
上级目录的子目录:
<YP:subcat  catid="parentid"> 
           <li class="ffws"><a href="http://gaoke0820.blog.163.com/blog/{$r.url}"  <if condition="$r['id'] eq $catid">style="color: #007CC2;"</if> >{$r.catname}</a></li>
</YP:subcat>

ps:其中$r['id'] eq $catid ,如果列表是文章,则是 $r['id'] eq $_GET['id']

4、<Yp:list>标签sql语句调用
例一:
<YP:list order="id desc"  sql="select * from rf_xhzhongxin where dingji=$catid or chaoji=$catid" >
            <li><a href="http://gaoke0820.blog.163.com/blog/" >{$r.title}</a></li>
 </YP:list>

例二:分别读取子栏目下的文章列表,该示例为3级分类,第一级catid 为 1
<YP:subcat  catid="1">
  <div class="notice fl box2 ovh" style="width:363px;">
    <div class="title"><p><a href="http://gaoke0820.blog.163.com/blog/{$r.url}">{$r.catname}</a></p></div>
    <div class="noticelist">
    <ul>
           <YP:list sql="select * from rf_article where catid in ($r[arrchildid]) order by id desc limit 10" id="res">
                 <li><span>[{$res.createtime|toDate=###,'m-d'}]</span><a href="http://gaoke0820.blog.163.com/blog/{$res.url}">{$res.title|str_cut=###,36}</a></li>
          </YP:list>
      </ul>
     </div>
   </div>
</YP:subcat>


5、<YP:catpos /> 面包削

<YP:catpos  catid="catid" space=" &gt; " />


6、列表页标题加入分页标记

列表页各分页如果标题都一样不利于SEO优化,怎么让他们有所不同呢?如下所示:

<title>{$seo_title}{if $_GET['p']}-第{$_GET['p']}页{/if}-{$site_name}</title>

你可能感兴趣的:(yourphp模板技巧)