Here's how to generate a sitemap.xml automatically in Empire CMS, step by step.
- Log in to the admin panel, usually at http://yourdomain.com/e/admin/, and use Empire CMS's custom page feature.
- In the admin panel, go to Categories → Add Custom Page. Choose "direct page," set the page name to "Sitemap," and change the file name to ../../sitemap.xml.

The page content (code) goes like this:
<?='<?xml version="1.0" encoding="UTF-8"?>'?> <? if ($_SERVER['HTTP_HOST'] =="www.yourdomain.com"){ $urlset='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" >'; $mobile=''; } else{ $urlset='<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/"> '; } ?> <?=$urlset?> <url> <loc>http://<?=$_SERVER['HTTP_HOST']?>[!--news.url--]</loc> <?=$mobile?> <changefreq>always</changefreq> <lastmod><?=date("Y-m-d",time())?></lastmod> <priority>1.000</priority> </url> [e:loop={"select * from [!db.pre!]enewsclass order by myorder",0,24,0}] <? if($bqr['classurl']=='') {$sccurl=$public_r['newsurl'].$bqr['classpath']."/";} else {$sccurl=$bqr['classurl']."/";} ?> <url> <loc>http://<?=$_SERVER['HTTP_HOST']?><?=$sccurl?></loc> <?=$mobile?> <changefreq>daily</changefreq> <lastmod><?=date("Y-m-d")?></lastmod> <priority>0.8000</priority> </url> [/e:loop] [e:loop={"select * from [!db.pre!]enewszt order by ztid",0,24,0}] <? if($bqr['zturl']=='') {$sccurl=$public_r['newsurl'].$bqr['ztpath']."/";} else {$sccurl=$bqr['zturl']."/";} ?> <url> <loc>http://<?=$_SERVER['HTTP_HOST']?><?=$sccurl?></loc> <?=$mobile?> <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_news order by newstime desc",0,24,0}] <url> <loc>http://<?=$_SERVER['HTTP_HOST']?><?=$bqsr[titleurl]?></loc> <?=$mobile?> <lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod> <changefreq>daily</changefreq> <priority>0.7000</priority> </url> [/e:loop] [e:loop={"select * from [!db.pre!]ecms_ku order by newstime desc",0,24,0}] <url> <loc>http://<?=$_SERVER['HTTP_HOST']?><?=$bqsr[titleurl]?></loc> <?=$mobile?> <lastmod><?=date('Y-m-d',$bqr[newstime])?></lastmod> <changefreq>daily</changefreq> <priority>0.7000</priority> </url> [/e:loop] </urlset>- Set the custom page to refresh on a schedule: System → Cron Jobs → Manage Refresh Tasks → Add a Scheduled Task, and choose "Refresh custom page - Sitemap."

That's essentially the whole setup. A couple of notes: the domain check in the code exists only so the PC and mobile versions get different xmlns attributes — the code works fine without it. And unlike most versions you'll find online, which make you hand-set the domain or category IDs, this one outputs the home page plus every category and article URL automatically. The one thing to watch is multiple content tables: if you have them, copy the block that outputs article URLs and change the table name. Questions are welcome in the comments.
Comments No Comments