如今有CMS之后建站变得非常简单,我们基本上不需要太精通的脚本语言,只要熟悉简单的HTML语言即可完成模板的制作,目前蜗牛基本上放弃WORDPRESS搭建网站(中文网站),而准备熟悉且精通国内主流的、小众轻巧的TYPECHO和ZBLOG PHP程序。在之前的\\”常用Typecho制作主题调用脚本及技巧\\”中整理到常用的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}
如果有遇到特别需要整理继续补充。
评论前必须登录!
立即登录 注册