1. 程式人生 > >phpcms一些常用程式碼標籤總結

phpcms一些常用程式碼標籤總結

1.欄目頁中呼叫當前位置:{catpos($catid)}

2.根據catid呼叫某個欄目url或者欄目名稱:{$CATEGORYS[欄目ID][url]}         {$CATEGORYS[欄目ID][catname]}

3.show頁面獲取文章瀏覽量:程式碼順序不要顛倒。

瀏覽量:<b id="hits"></b>次
                    <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>

4.show頁面,呼叫文章上一篇下一篇:

<a href="{$previous_page[url]}" title="{$previous_page[title]}">
                {$previous_page[title]}
        </a>
        </span>                
        <span class="in_page_next">
        下一篇:
        <a href="{$next_page[url]}" title="{$next_page[title]}">{$next_page[title]}</a>
        

5.show頁面獲取相關文章,關鍵字相同:

{pc:content action="relation" relation="$relation" keywords="$rs[keywords]" catid="$catid" num="6" id="$id"}
                        {loop $data $r}
                        <li><a href="{$r[url]}">{$r[title]}</a></li>
                        {/loop}
                        {/pc}

6.js手機站和pc站域名轉換:

<script>
var domain = window.location.host;//獲取當前域名

  var url = window.location.href;
 if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
      if(domain.substr(0,4)=="www."){
	
              var turl = url.replace(domain,"m.域名");

	window.location.href = turl;
	
      } 
}else{
     if(domain.substr(0,2)=="m."){
	
              var turl = url.replace(domain,"www.域名
");

	window.location.href = turl;
	
      } 
}
</script>

7.首頁呼叫欄目名稱和url

<li {if !$catid}class="hover"{/if}><a href="{APP_PATH}">網站首頁<span>HOME</span></a></li>
                {pc:content action="category" catid="0" siteid="$siteid" order="listorder ASC" }
                {loop $data $r}
                <li {if $catid == $r[catid]}class="hover"{/if}><a href="{$r[url]}">{$r[catname]} <span>{$r[catdir]}</span></a></li>
                {/loop}
                {/pc}

8.seo優化,首頁標題描述和關鍵詞呼叫後臺填寫的:

<title>{if !$catid}{$SEO['site_title']}{else}{if isset($SEO['title'])}{$SEO['title']}{elseif
        isset($CAT[catname])}{$CAT[catname]}{/if}{$SEO['name']}{/if}</title>
    <meta name="Keywords" content="{$SEO['keyword']}">
    <meta name="Description" content="{$SEO['description']}">