我正在使用symfony 1.0.6。如何添加規範標籤從相同鏈接派生的頁面?
在我的網站我有兩個網址。
http://newe4s.com/news/articles/view/033/job-news-and-information
和
http://newe4s.com/news/articles/view/033/job-news-and-information/graduate/Connections-help-graduates-get-jobs
現在,所有的新文章使用相同的佈局和兩個以上的鏈接從數據庫中獲得相同的數據。 Google正在報告內容重複,因爲它獲取的是同一內容的多個網址。 當我尋找一個解決方案,我得到了使用「規範」的結構解決這個問題需要
<link rel="canonical" href="http://newe4s.com/news/articles/view/033/job-news-and-information />
在頁面
http://newe4s.com/news/articles/view/033/job-news-and-information/graduate/Connections-help-graduates-get-jobs
的頭部分,但問題被加入這裏,無論是使用相同的佈局和基於文章ID(上例中的033),數據被提取並顯示。 我無法更改或硬編碼規範href。
有沒有任何方法在action.class或模板文件中手動添加鏈接標記?
嗨無論打印我已經創建了/ lib下一個幫手/ symfony/helper作爲CanonicaHelper.php,我粘貼了包含add_link的代碼。 然後在模板我layout.php中稱爲add_link()函數,並添加include_slot(「鏈接」) 我應該重新命名include_slot(「鏈接」),以include_slot(「規範」)......我在這兩個方面嘗試。它不是wortking –
我已經編輯我的回答(你需要使用'use_helper') – j0k
您好我無法正常發佈在評論框我的代碼。所以我回答了我自己的問題。請讓我知道是否正確。 –