本篇文章主要針對百度SITEMAP規范改版以后,帝國百度SITEMPA XML地圖如何生成的問題。其實和以往的代碼規范大同小異,改版以后只需要提交內容鏈接資源即可,也就是集合性的XML已經不再支持。
我們用帝國的自定義頁面來實現這個功能:
1.后臺-欄目-自定義頁面-管理自定義頁面-增加:
頁面模式:直接頁面式
頁面名稱:XML地圖
文件名:../../sitemap.xml
標題關鍵字和描述隨便寫。
2.頁面內容代碼:
<?='<?xml version="1.0" encoding="UTF-8"?>'?>
<urlset>
[e:loop={"select * from [!db.pre!]ecms_news order by newstime DESC",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>daily</changefreq>
<priority>0.8000</priority>
</url>
[/e:loop]
</urlset>
其中:ecms_news 為你的模型名稱,改為你的模型名稱即可。如果多個模型可以用多個自定義頁面來做。也在一個自定義頁面通過復制多個如下代碼來實現:
[e:loop={"select * from [!db.pre!]ecms_news order by newstime DESC",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>daily</changefreq>
<priority>0.8000</priority>
</url>
[/e:loop][e:loop={"select * from [!db.pre!]ecms_down order by newstime DESC",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>daily</changefreq>
<priority>0.8000</priority>
</url>
[/e:loop]