標籤:des style http io 使用 ar 檔案 div sp
文章來源:www.bayinmao.com
phpcms v9 單頁面調用seo META Title和seo META Keywords
因為單頁面是預設調用seo META Description的,所以現在弄一下調用seo META Title和seo META Keywords.大家應該都是在header標頭檔裡寫上{if isset($SEO[‘title‘]) && !empty($SEO[‘title‘])}{$SEO[‘title‘]}{/if}{$SEO[‘site_title‘]}這個的吧。
這個$SEO的變數是在/phpcms/modules/content/index.php裡的。所以要找到這個$SEO這個變數。v9的代碼寫的很人性化。有注釋標明那些是單頁面的代碼。我直接找到單頁面那個代碼塊。發現這裡的$SEO變數如下:$SEO = seo($siteid, 0, $title,$setting[‘meta_description‘],$keywords);seo這個函數所在檔案/phpcms/libs/functions/global.func.php這個函數的聲明為:function seo($siteid, $catid = ‘‘, $title = ‘‘, $description = ‘‘, $keyword = ‘‘) 研究一下它的定義,發現第二個參數是調用欄目seo META Title和seo META Keywords使用的,如果是0就不調用。修改方法。將上面$SEO的賦值寫成$SEO = seo($siteid, $catid, $title,$setting[‘meta_description‘],$keywords);在網上查了一下,還要修改/phpcms/modules/content/class/html.class.php裡面的單頁面$SEO變數(這個應該是產生靜態化用的。)。找到有注釋標明那些是單頁面的代碼一樣修改為:$SEO = seo($siteid, $catid, $title,$setting[‘meta_description‘],$keywords);
關於標題有重複,可以修改一下seo META Title這樣看起來會好看點。還有標題後面多了一個杠。我將seo這個函數所在檔案/phpcms/libs/functions/global.func.php裡面的$seo [‘title‘] = (isset ( $title ) && ! empty ( $title ) ? $title : ‘‘) . (isset ( $cat [‘setting‘] [‘meta_title‘] ) && ! empty ( $cat [‘setting‘] [‘meta_title‘] ) ? $cat [‘setting‘] [‘meta_title‘] . ‘ - ‘ : (isset ( $cat [‘catname‘] ) && ! empty ( $cat [‘catname‘] ) ? $cat [‘catname‘] . ‘ - ‘ : ‘‘));修改成:$seo [‘title‘] = (isset ( $title ) && ! empty ( $title ) ? $title . ‘_‘ : ‘‘) . (isset ( $cat [‘setting‘] [‘meta_title‘] ) && ! empty ( $cat [‘setting‘] [‘meta_title‘] ) ? $cat [‘setting‘] [‘meta_title‘] : (isset ( $cat [‘catname‘] ) && ! empty ( $cat [‘catname‘] ) ? $cat [‘catname‘]: ‘‘));
phpcms單網頁seo標題解決方案