ZBlog PHP主题模板标签调用文档整理

李洋博客 2015-12-15 8.47 K阅读 1评论

温馨提示:这篇文章已超过3026天没有更新,请注意相关的内容是否还可用!

ZBlog PHP主题模板标签调用文档整理 第1张

如今有CMS之后建站变得非常简单,我们基本上不需要太精通的脚本语言,只要熟悉简单的HTML语言即可完成模板的制作,目前常用Typecho制作主题调用脚本及技巧中整理到常用的TYPECHO主题制作的时候需要用到的调用脚本,然后也制作了第一个主题。

今天用这篇文章整理常用的zblog PHP主题模板标签调用文档,以便以后在使用的时候直接复制。

第一、内容页面面包屑导航

{if $article.Type==ZC_POST_TYPE_ARTICLE}
当前位置 :<a href="{$host}">网站首页</a> - {if $article.Category.ParentID > 0}{template:post-nav}{else}>> <a href="{$article.Category.Url}" title="查看' {$article.Category.Name} '中的全部文章">{$article.Category.Name}</a>{/if}
{/if}

放置在single.php文章中,判断在内容页面中调用面包屑导航。

第二、调用内容第一张图作为缩略图

{php} $pattern="/<[img|IMG].*src=[\'|\"](.*(:[\.gif|\.jpg|\.png]))[\'|\"].*[\/]>/"; $content = $article->Content; preg_match_all($pattern,$content,$matchContent); if($matchContent[1][0]) $temp=$matchContent[1][0]; else $temp="$host/zb_users/theme/$theme/style/img/pic.png"; //默认图片 {/php}<a href="{$article.Url}" title="{$article.Title}"><img src="{$temp}" alt="{$article.Title}" /></a>

这个用途比较多的,比如用来制作图文主题调用第一张图片或者没有图片时候默认图片显示,这样就不需要用插件。需要注意的是,图片最好定义尺寸。

第三、TITLE/关键字/描述调用

{if $type=='index'&&$page=='1'}
<title>{$name}-{$title}</title>
<meta name="description" content="首页描述" />
<link rel="stylesheet" rev="stylesheet" href="{$host}zb_users/theme/{$theme}/style/{$style}.css" type="text/css" media="all"/>
<link rel="alternate" type="application/rss+xml" href="{$feedurl}" title="{$name}" />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="{$host}zb_system/xml-rpc/rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="{$host}zb_system/xml-rpc/wlwmanifest.xml" />
{elseif $type=='article'}
<title>{$title} _ {$name}</title>
<meta name="description" content="{php}echo preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),80)).'...');{/php}" />
<link rel="stylesheet" rev="stylesheet" href="{$host}zb_users/theme/{$theme}/style/{$style}.css" type="text/css" media="all"/>
{else}
<title>{$title} _ {$name}</title>
<link rel="stylesheet" rev="stylesheet" href="{$host}zb_users/theme/{$theme}/style/{$style}.css" type="text/css" media="all"/>
{/if}
<script src="{$host}zb_system/script/common.js" type="text/javascript"></script>
<script src="{$host}zb_system/script/c_html_js_add.php" type="text/javascript"></script>
{$header}

一般我是用这个文档作为HEAD的头部调用,可以定义标题和页面描述。

第四、分类列表调用

{foreach GetList(调用条数,分类ID) as $related}
<li><span>{$related.Time('Y-m-d')}</span><a href="{$related.Url}">{$related.Title}</a></li>
{/foreach}
{foreach GetList(调用条数,$article.Category.ID) as $related}
<li><span>{$related.Time('Y-m-d')}</span><a href="{$related.Url}">{$related.Title}</a></li>
{/foreach}

如果有遇到特别需要整理继续补充。

转载老左博客: http://www.laozuo.org/2154.html

文章版权声明:除非注明,否则均为老李笔记原创文章,转载或复制请以超链接形式并注明出处。

发表评论

快捷回复: 表情:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog
评论列表 (有 1 条评论,8465人围观)
网友昵称:李洋博客
李洋博客 V 博主 Sogou Explorer Windows 7 x64 沙发
2015-12-16 来自辽宁 回复
评论。、
取消
微信二维码
微信二维码
支付宝二维码