李涛自留地
回到顶部
首页 > 建站 > ZblogPhp主题制作学习系列二 Header.php中常用的调用标签

ZblogPhp主题制作学习系列二 Header.php中常用的调用标签

Zblogphp的Header.php主要是调用网站Tdk标签和前端页面的Css样式的文件,Header.php应该是比较关键的一个文件,如果Header.php中没有写好网站各个页面的Tdk,那么势必会影响网站权重,所以我觉得Zblogphp的Header.php还是比较重要的,下面是近两天整理的Zblogphp的Header.php文件中可能会用到的调用标签。

{$zblogphp}//zblogphp的使用版本号
{$theme}//当前使用的主题目录名
{$style}//当前使用的主题的前端样式表的文件名
{$themeinfo['modified']}//当前使用的主题的应用版本号
{$name}//网站名称
{$title}//首页的时候是网站副标题,分类页的时候是分类名称,文章页面的时候是文章标题。
{$host}//网站域名

以上就是在默认主题中发现并自己理解的这些标签的大致意思。默认标签中首页标题title调用是把{$name}放在了{$title}之前的位置,如果title部分这个地方不做调整的话,那么文章页的title部分就是:网站名称-文章标题,这样看着感觉十分怪异,可以将两个标签进行位置调整。

首页的副标题在网站后台的网站设置——网站副标题中进行填写即可。

ZblogPhp主题制作学习系列二 Header.php中常用的调用标签

在别的主题中的看到的一个我觉得还不错的Tdk判断语句,判断出了不同页面下,各种不同的Tdk组合,具体代码如下:

{if $type=='article'}//文章类型Tdk:
  <title>{$title}_{$article.Category.Name}_{$name}</title>
  {php}
  $keywords = $article->TagsToNameString();
  $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(FormatString($article->Content,'[nohtml]'),135)).'...');
  {/php}
  <meta name="keywords" content="{$keywords}">
  <meta name="description" content="{$description}">
  <meta name="author" content="{$article.Author.StaticName}">
  <link rel="canonical" href="{$article.Url}">
{elseif $type=='page'}//页面类型Tdk:
  <title>{$title}_{$name}_{$subname}</title>
  <meta name="keywords" content="{$title},{$name}">
  {php}
  $description = preg_replace('/[\r\n\s]+/', ' ', trim(SubStrUTF8(FormatString($article->Content,'[nohtml]'),135)).'...');
  {/php}
  <meta name="description" content="{$description}">
  <meta name="author" content="{$article.Author.StaticName}">
  <link rel="canonical" href="{$article.Url}">
{elseif $type=='index'}//首页
  <title>{$name}{if $page>'1'}_第{$pagebar.PageNow}页{/if}_{$subname}</title>
  <meta name="keywords" content="{$zbp->Config('mzDanron')->keywords},{$name}">
  <meta name="description" content="{$zbp->Config('mzDanron')->description}_{$name}_{$title}">
  <meta name="author" content="{$zbp.members[1].Name}">
  <link rel="canonical" href="{$zbp.fullcurrenturl}">
{else}
  {php}
  $title = preg_replace('/\s.+$/','',$title);
  $fixTitle = "";
  $fixDesc = "";
  if (isset($pagebar)){
  $fixTitle = "_第{$pagebar->PageNow}页";
  $fixDesc = "_当前是第{$pagebar->PageNow}页";
  }
  {/php}
  <title>{$title}_{$name}{$fixTitle}</title>
  <meta name="keywords" content="{$title},{$name}">
  <meta name="description" content="{$title}_{$name}{$fixDesc}">
  <meta name="author" content="{$zbp.members[1].Name}">
  <link rel="canonical" href="{$zbp.fullcurrenturl}">
{/if}

以上就是近期学习Zblogphp主题制作header.php常用的一些标签。

若非作者标注皆为李涛自留地原创文章,转载或复制请以超链接形式并注明出处。