麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > CMS > Z-Blog > 正文

Z-BlogPHP主題教程(十二)ZBlogPHP主題制作技巧

2024-09-06 23:00:59
字體:
來源:轉載
供稿:網友

Z-BlogPHP主題教程(十二)ZBlogPHP主題制作技巧 主題制作技巧 第1張

同分類文章列表調用

{foreach GetList(調用條數,分類ID) as $related}<li><span>{$related.Time('Y-m-d')}</span><a href="{$related.Url}">{$related.Title}</a></li>{/foreach}

獲取大目錄下的所有文章(包括子目錄文章):

{foreach Getlist(調用條數,分類ID,null,null,null,null,array('has_subcate'=>true)) as $related}<li><span>{$related.Time('Y-m-d')}</span><a href="{$related.Url}">{$related.Title}</a></li>{/foreach}

調用其它數據參考php/133.html" target="_blank" style="box-sizing: border-box; color: rgb(160, 206, 78); background-color: transparent; text-decoration: none;">文章標簽。

注意:此處需要使用foreach循環中as后面變量名,如案列中使用的$related,如需調用標題則用{$related.Title},而并非是 {$article.Title}。

網站關鍵詞、描述添加

{if $type=='article'}  <title>{$title}_{$article.Category.Name}_{$name}</title>

  {php}

    $aryTags = array();

    foreach($article->Tags as $key){

      $aryTags[] = $key->Name;

    }

    if(count($aryTags)>0){

        $keywords = implode(',',$aryTags);

    } else {

        $keywords = $zbp->name;

    }

    $description = preg_replace('/[/r/n/s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');

  {/php}  <meta name="keywords" content="{$keywords}"/>

  <meta name="description" content="{$description}"/>

  <meta name="author" content="{$article.Author.StaticName}">{elseif $type=='page'}  <title>{$title}_{$name}_{$subname}</title>

  <meta name="keywords" content="{$title},{$name}"/>

  {php}

    $description = preg_replace('/[/r/n/s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...');

  {/php}  <meta name="description" content="{$description}"/>

  <meta name="author" content="{$article.Author.StaticName}">{elseif $type=='index'}  <title>{$name}{if $page>'1'}_第{$pagebar.PageNow}頁{/if}_{$subname}</title>

  <meta name="Keywords" content="自定義關鍵詞,{$name}">

  <meta name="description" content="自定義描述_{$name}_{$title}">

  <meta name="author" content="{$zbp.members[1].StaticName}">{else}  <title>{$title}_{$name}_第{$pagebar.PageNow}頁</title>

  <meta name="Keywords" content="{$title},{$name}">

  <meta name="description" content="{$title}_{$name}_當前是第{$pagebar.PageNow}頁"> 

  <meta name="author" content="{$zbp.members[1].StaticName}">{/if}

評論數判斷

{if $article.CommNums==0}

暫無留言

{elseif $article.CommNums==1}

僅有1條留言

{else}

已有{$article.CommNums}條留言

{/if}

頁面判斷

{if $type=='index'&&$page=='1'}  /*判斷首頁*/

{if $type=='category'}  /*判斷分類頁*/

{if $type=='article'}  /*判斷日志頁,不含獨立頁面,{if $article.Type==ZC_POST_TYPE_ARTICLE}(另一方案)*/

{if $type=='page'}  /*判斷獨立頁面*/

{if $type=='author'}  /*判斷用戶頁*/

{if $type=='date'}  /*判斷日期頁*/

{if $type=='tag'}  /*判斷標簽頁*/

示例:首頁和分類列表頁分離

在index.php文件里作判斷,分離模板。比如:

{if $type=='index'&&$page=='1'} 

{template:c_index}

{else}

{template:c_list}

{/if}

然后新建兩個相應的模板文件:c_index.php和c_list.php

隨機獲得文章中的四張圖片中的一張 

適用于多圖站點,在模板文件中使用:

{php}

$temp=mt_rand(1,4);

$pattern="/<[img|IMG].*?src=[/'|/"](.*?(?:[/.gif|/.jpg|/.png]))[/'|/"].*?[//]?>/";

$content = $article->Content;

preg_match_all($pattern,$content,$matchContent);

if(isset($matchContent[1][0])) 

$temp=$matchContent[1][0];

else

$temp=$zbp->host."zb_users/theme/$theme/style/images/random/$temp.jpg";

//需要在相應位置放置4張jpg的文件,名稱為1,2,3,4

{/php} 

<img src="{$temp}" />

僅顯示文字的文章簡介調用方法

{SubStrUTF8(TransferHTML($article.Intro,"[nohtml]"),200)}

分類目錄面包屑的代碼編寫

{php}

$html='';

function navcate($id){

global $html;

$cate = new Category;

$cate->LoadInfoByID($id);

$html ='>>  <a href="' .$cate->Url.'" title="查看' .$cate->Name. '中的全部文章">' .$cate->Name. '</a> '.$html;

if(($cate->ParentID)>0){navcate($cate->ParentID);}

}

navcate($article->Category->ID);

global $html;

echo $html;

{/php}

顯示相關文章

搜索$article的相關文章(ZC_RELATEDLIST_COUNT選項默認為10)

PHP

$array=GetList($zbp->option['ZC_RELATEDLIST_COUNT'],null,null,null,null,null,array('is_related'=>$article->ID));

在模板中,獲取并輸出獲取到的相關文章代碼參考如下

{$array=GetList($zbp->option['ZC_RELATEDLIST_COUNT'],null,null,null,null,null,array('is_related'=>$article->ID));}<ul id="related">{foreach $array as $related}  <li>

  <span class="time">{$related.Time('m-d')}</span>

  <span class="title"><a href="{$related.Url}" title="{$related.Title}">{$related.Title}</a></span>

  </li>{/foreach}</ul>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 刘亦菲一区二区三区免费看 | 国产羞羞网站 | 日本在线免费观看视频 | 色综合久久久久久久久久久 | 国产一有一级毛片视频 | 亚洲国产视频网 | 亚洲国产成人久久一区www妖精 | 日韩毛片在线看 | 欧美黄色视屏 | 免费网站看毛片 | 日本不卡视频在线观看 | 久久中出 | 国产精品高潮视频 | 一本色道精品久久一区二区三区 | 精品久久久久久久久久久αⅴ | 国产美女爽到喷白浆的 | 国产午夜精品久久久 | 欧美一级精品片在线看 | 国产精品免费一区二区三区都可以 | 91成人亚洲 | 免费a级片视频 | 一级毛片电影网 | 国产大片全部免费看 | 在线免费av观看 | 欧美在线观看视频一区二区 | 国产九色视频在线观看 | 免费看污视频在线观看 | 黑人三级毛片 | 99综合视频 | 久久久久久久久久亚洲精品 | 黄色成人小视频 | 七首小情歌泰剧在线播放 | 欧美成人精品一区二区男人小说 | 美女av在线免费观看 | www噜噜偷拍在线视频 | 免费在线观看午夜视频 | 特级黄aaaaaaaaa毛片 | 久久不射电影网 | 久久国产精品小视频 | 福利免费视频 | 一级在线观看 |