首先以zblogPHP分類增加自定義標題、關鍵詞、描述功能為例:
1、在include.php的function ActivePlugin_模板id(){中掛載:
Add_Filter_Plugin('Filter_Plugin_Category_Edit_Response','ydmao_cate_seo');//分類自定義字段
2、在function ActivePlugin_模板id(){.....}后加入:
function ydmao_cate_seo(){ global $zbp,$cate; echo '<div id="alias" class="editmod"> <span class="title">當前分類標題、關鍵詞、描述<font color="#FF0000">(不填寫則按主題默認顯示)</font></span><br /> <strong>標題</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_catetitle" value="'.htmlspecialchars($cate->Metas->ydmao_catetitle).'"/><br> <strong>關鍵詞</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_catekeywords" value="'.htmlspecialchars($cate->Metas->ydmao_catekeywords).'"/><br> <strong>描述</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_catemiaoshu" value="'.htmlspecialchars($cate->Metas->ydmao_catemiaoshu).'"/> </div>'; }
以上兩步就可以在zblogPHP模板的分類中加入了三個SEO字段,剩下的就是如何調用出來,而且必須調用出來,不然以上操作都沒有任何意義。
所以需要在模板的header.php中的</head>前加入:
{if $type=='category'} <!-- 判斷在分類頁面時候 --> <title>{if $category->Metas->ydmao_catetitle}{$category.Metas.ydmao_catetitle}{else}{$title}_{$name}{if $page>'1'}_第{$pagebar.PageNow}頁{/if}{/if}</title> <meta name="Keywords" content="{if $category->Metas->ydmao_catekeywords}{$category.Metas.ydmao_catekeywords}{else}{$title},{$name}{/if}" /> <meta name="description" content="{if $category->Metas->ydmao_catemiaoshu}{$category.Metas.ydmao_catemiaoshu}{else}{$category.Intro}_{$name}{if $page>'1'}_當前是第{$pagebar.PageNow}頁{/if}{/if}" /> {else} 這里是zblog模板原有的標題關鍵詞描述等代碼 {/if}
注:代碼中的ydmao為模板的應用ID,切記!!!
以上完成后,在編輯任一分類的時候,就會顯示:
而zblog模板的tag標簽也加入SEO(標題關鍵詞描述)也和這個基本一樣,如下:
1、同樣是掛載:
Add_Filter_Plugin('Filter_Plugin_Tag_Edit_Response','ydmao_tag_seo');//tag自定義字段
2、之后加入:
//tag SEO function ydmao_tag_seo(){ global $zbp,$tag; echo '<div id="alias" class="editmod"> <span class="title">當前TAG標題、關鍵詞、描述<font color="#FF0000">(不填寫則按主題默認顯示,注:此功能為當前模板自帶)</font></span><br /> <strong>標題</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_tagtitle" value="'.htmlspecialchars($tag->Metas->ydmao_tagtitle).'"/><br> <strong>關鍵詞</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_tagkeywords" value="'.htmlspecialchars($tag->Metas->ydmao_tagkeywords).'"/><br> <strong>描述</strong><br> <input type="text" style="width:75%;" name="meta_ydmao_tagmiaoshu" value="'.htmlspecialchars($tag->Metas->ydmao_tagmiaoshu).'"/> </div>'; }
3、模板中加入:
{if $type=='tag'} <title>{if $tag->Metas->ydmao_tagtitle}{$tag.Metas.ydmao_tagtitle}{if $page>'1'}_第{$pagebar.PageNow}頁{/if}{else}{$tag.Name}_{$name}{if $page>'1'}_第{$pagebar.PageNow}頁{/if}_{$subname}{/if}</title> <meta name="Keywords" content="{if $tag->Metas->ydmao_tagkeywords}{$tag.Metas.ydmao_tagkeywords}{else}{$tag.Name}{/if}"> {if $tag.Intro || $tag->Metas->ydmao_tagmiaoshu}<meta name="description" content="{if $tag->Metas->ydmao_tagmiaoshu}{$tag.Metas.ydmao_tagmiaoshu}{else}{$tag.Intro}{/if}">{/if} {/if}