Tag标签调用代码
添加无逗号隔开的文章tag标签
{if $article.Tags} {foreach $article.Tags as $tag} {$tag.Name} {/foreach} {/if}
添加有逗号隔开的文章tag标签
{if $article.Tags} {php} $counts = count($article->Tags); $i=0; {/php} {foreach $article.Tags as $tag} {php} $i++ {/php} {if $i == $counts} {$tag.Name} {else} {$tag.Name}, {/if} {/foreach} {/if}
添加指定数量的文章tag标签(以调用3个tag标签为例)
{php} $i=0 {/php} {if $article.Tags} {foreach $article.Tags as $key => $tag} {php} $i++ {/php} {if $i < 4} {$tag.Name} {/if} {/foreach} {/if}
自用常用Tag添加方法,逗号分隔,最后Tag删除逗号
{php} $counts = count($article->Tags); $i=0 {/php} {if $article.Tags} {foreach $article.Tags as $tag} {php} $i++ {/php} {if $i < 6} {if $i == 5 || $i == $counts} <a href="{$tag.Url}">{$tag.Name}</a> {else} <a href="{$tag.Url}">{$tag.Name}</a>, {/if} {/if} {/foreach} {/if}
随机调用25个tag标签
模板根目录下include.php内容: function name_Theme_Get_rdTags() { global $zbp,$str; $str = ''; $array = $zbp->GetTagList('', '', array('rand()'=>' '), array(25), ''); foreach ($array as $tag) { $str .= "<a href=\"{$tag->Url}\" class=\"tag-cloud-link tag-link-{$tag->ID} tag-link-position-1\" style=\"font-size: 8pt;\" aria-label=\"{$tag->Name} ({$tag->Count}个项目)\">{$tag->Name}</a>"; } return $str; } 使用方法: {name_Theme_Get_rdTags()}
Tag文章调用代码
Tag标签页文章列表
{php} $result = GetList(array('tags' => $tag->Name)); {/php} {foreach $result as $article} {$article.Url} {$article.Title} {$article.Time("PostTime","Y-m-d H:i:s")} {/foreach}
文章相关调用代码
最新文章12篇
{php} $articles = GetList(array('count'=>12)); {/php} {foreach $articles as $article} <li class="list "> <div class="thumbnail"><a href="{$article.Url}" title="{$article.Title}" target="_blank"><img src="{$article.Img}" /></a></div> <p><i class="icon-right-open-mini"></i><a href="{$article.Url}" title="{$article.Title}" target="_blank">{$article.Title}</a></p> </li> {/foreach}
热门文章12篇
{php} $stime = time(); $ytime = 365*24*60*60; $ztime = $stime-$ytime; $order = array('log_ViewNums'=>'DESC'); $where = array(array('=','log_Status','0'),array('>','log_PostTime',$ztime)); $array = $zbp->GetArticleList(array('*'),$where,$order,array(12),''); {/php} {foreach $array as $article} <li><i class="a1">1</i> <a href="{$article.Url}" title="{$article.Title}" target="_blank">{$article.Title}</a></li> {/foreach}
随机文章10篇
{php} $order = array('rand()'=>''); $where = array(array('=','log_Status','0')); $array = $zbp->GetArticleList(array('*'),$where,$order,array(10),''); {/php} {foreach $array as $related} <li><a href="{$related.Url}">{$related.Title}</a></li> {/foreach}
相关文章4篇
{php} $result = GetList(array('count'=>4,'is_related' => $article->ID));//根据文章ID获取4篇文章 {/php} {foreach $result as $related} <li> <p><a href="{$related.Url}" title="{$related.Title}" target="_blank">{$related.Title}</a></p> </li> {/foreach}
上一篇,下一篇
<p>上一篇: {if $article.Prev} <a href="{$article.Prev.Url}" title="{$article.Prev.Title}">{$article.Prev.Title}</a> {/if} </p> <p>下一篇: {if $article.Next} <a href="{$article.Next.Url}" title="{$article.Next.Title}">{$article.Next.Title}</a> {/if} </p>
上一页,下一页
//系统翻页,无需创建pagebar.php文件 {if count($articles) > 0} {template:pagebar} {/if} //简单翻页示例 <li><a href="{$pagebar.prevbutton}">上一页</a></li> <li><a href="">{$pagebar.PageNow}</a></li> <li><a href="{$pagebar.nextbutton}">下一页</a></li>
轮播图调用代码
代码内指定文章显示轮播图
{php} //指定轮播主图5张大图片(根据下方文章id值确定) $posts[] = GetPost(array('id'=>1,'only_article' => true)); $posts[] = GetPost(array('id'=>2,'only_article' => true)); $posts[] = GetPost(array('id'=>3,'only_article' => true)); $posts[] = GetPost(array('id'=>4,'only_article' => true)); $posts[] = GetPost(array('id'=>5,'only_article' => true)); {/php} {foreach $posts as $newpost} <li> <a href="{$newpost.Url}" title="{$newpost.Title}"> <img src="{$newpost.Img}" alt="{$newpost.Title}"><p class="flex-caption">{$newpost.Title}</p></a> </li> {/foreach}
所有分类调用代码
获取所有分类代码
{php} $postArray = $zbp->categorysbyorder;//获取所有分类数据,返回二维索引数组 $postArray = array_values($postArray);//数组键重新从0开始 $key_id = 0; //使用数组中第1个分类键为0数据 $remove = array();//声明remove为数组(差集去除使用) if(array_key_exists($key_id,$postArray)){ $remove[] = $postArray[$key_id];//判断$key_id的键是否存在,存在把一维数组转换成二维(差集去除必须是二维数组) $result = array_diff($postArray, $posts); //计算数组差集,去除第1个分类数据,得到其他所有array数据 } {/php} {foreach $result as $cate} {$cate.Name} {php} $articles = GetList(array('count'=>4,'cate' => $cate->ID)); {/php} {foreach $articles as $article} {$article.Title} {$article.Category.Name} {$article.Time("PostTime","Y-m-d H:i:s")} {/foreach} {/foreach}
描述摘要调用代码
摘要从文章正文截取135个字符
{php} $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),135)).'...'); {/php} {$description}
模板内注释语法
模板首行注释集合
{* Template Name:公共头部 *} {* Template Name:公共底部 *} {* Template Name:首页页面 *} {* Template Name:单页页面 *} {* Template Name:列表页页面 *} {* Template Name:分类页页面 *} {* Template Name:文章页页面 *} {* Template Name:作者页页面 *} {* Template Name:标签页页面 *} {* Template Name:搜索页页面 *} {* Template Name:404页页面 *}
index.php内容
入口文件判断代码
{if $type=='index'} {template:c_index} {elseif $type=='category'} {template:category} {elseif $type=='article'} {template:single} {elseif $type=='page'} {template:page} {elseif $type=='author'} {template:author} {elseif $type=='tag'} {template:c_tag} {/if}
header.php内容
头文件嵌入代码
{template:header}
头文件title keywords description代码
{if $type=='article'} <title>{$title} - {$name}</title> {php} $keywords = $article->TagsName; $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}</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}_{$subname}</title> <meta name="Keywords" content="{$name}"> <meta name="description" content="{$name}_{$title}_{$subname}"> <meta name="author" content="{$zbp.members[1].StaticName}"> {elseif $type=='category'} <title>{$category.Name}_{$name}</title> <meta name="Keywords" content="{$category.Name},{$name}"> <meta name="description" content="{$category.Name}_{$name}"> {elseif $type=='author'} <title>{$author.Name} - {$name}</title> <meta name="Keywords" content="{$author.Name},{$name}"> <meta name="description" content="{$author.Name}_{$name}"> {elseif $type=='tag'} <title>{$tag.Name} - {$name}</title> <meta name="Keywords" content="{$tag.Name},{$name}"> <meta name="description" content="{$tag.Name}_{$name}"> {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}
footer.php内容
脚文件嵌入代码
{template:footer}
search.php内容
搜索路径URL
{$host}zb_system/cmd.php?act=search //示例: <input type="text" name="q" placeholder="输入关键词搜索..."> <button type="submit">搜索</button>
获取搜索词代码
{php} $act = GetVars("q", "GET"); {/php} {$act}
搜索页文章列表+调用系统翻页
{foreach $articles as $article} {/foreach} {if count($articles)>0} {template:pagebar} {/if}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)