{php}
if($type=='index'){
$keywords = $zbp->option['ZC_BLOG_SUBNAME'];
$description = $zbp->option['ZC_BLOG_COPYRIGHT'];
}elseif($type=='category'){
$keywords = $category->Name;
$description = $category->Intro;
}elseif($type=='article'||$type=='page'){
$aryTags = array();
foreach($article->Tags as $key){
$aryTags[] = $key->Name;
}
if(count($aryTags)>0) $keywords = implode(',',$aryTags);
$description = preg_replace('/[\r\n\s]+/', '', trim(SubStrUTF8(TransferHTML($article->Content,'[nohtml]'),100)).'...');
}{/php}
{if isset($keywords)&&strlen($keywords)>0}
<meta name="keywords" content="{$keywords}" />
{/if}
{if isset($description)&&strlen($description)>0}<meta name="description" content="{$description}" />
{/if}
$description里面的100是显示内容里面的前100个字符,可以根据自己需要更改。
$article->Content是显示的文章内容,也可以改成$article->Intro,显示文字摘要。
页面判断
{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'} /*判断标签页*/