phpcms單網頁seo標題解決方案

來源:互聯網
上載者:User

標籤: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標題解決方案

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.