帝国官方虽然出了sitemap插件,但是不是很好用。
下面给出一个自定义制作sitemap.xml的方法。
登陆帝国CMS的后台,然后点击栏目---》点击增加自定义页面
然后改文件名为sitemap.xml
在页面内容区域填写以下代码:
<?='<?xml versiON="1.0" encoding="UTF-8"?>'?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>[!--news.url--]</loc><lastmod><?=date("Y-m-d");?></lastmod><changefreq>always</changefreq><priority>1.0</priority></url>[e:loop={'select classid,classname,classpath,wburl from [!db.pre!]enewsclass where bclassid=0 and showclass=0 and (classid<>52 and classid<>24) order by myorder',0,24,0}]<?phpif(empty($bqr[wburl])){ $sccurl= $public_r[newsurl].$bqr[classpath];} else { $sccurl= $bqr[wburl];}?><url><loc><?=$sccurl?>/</loc><lastmod><?=date("Y-m-d");?></lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>[/e:loop][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>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_download 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.8</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_jianzhu 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.8</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_jiegou 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.8</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_jsps order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_cntf order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_dianqi order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_fjyl order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_ct order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop][e:loop={"select * from [!db.pre!]ecms_tuji order by newstime DESC",0,24,0}]<url><loc><?=$bqsr[titleurl]?></loc><lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod><changefreq>never</changefreq><priority>0.5</priority></url>[/e:loop]</urlset>
取其中一节说一下
[e:loop={"select * from [!db.pre!]ecms_tuji order by newstime DESC",0,24,0}]
<url>
<loc><?=$bqsr[titleurl]?></loc>
<lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod>
<changefreq>never</changefreq>
<priority>0.5</priority>
</url>
[/e:loop]
这是一个数据表的方法,[!db.pre!]ecms_tuji这个字段中的tuji为你自己的数据表的名字,你有多少个数据表,就重复多少遍。
未经允许不得转载:Just My Socks中文教程网 » 给出一个帝国CMS自定义制作sitemap.xml的方法