以前发过一个方案,但更新后要手动生成(按扭),更适合数据较多时用。现在这个是用伪静态的思路做的,用起来更方便,就像你改模版一样,并且适用于所有版本的JTBC。已通过Google测试,能正常使用。这个不适合数据量较大的站使用! 步骤 一 还是选建调用模板: <item> <name><![CDATA[sitemap]]></name> <tpl_default><![CDATA[{@} <url> <loc>http://seeble.cn/{$=ii_curl('{$baseurl}', ii_iurl('detail', {$id}, {$urltype}, 'folder={$createfolder};filetype={$createfiletype};time={$time}'))}</loc> <lastmod>{$=ii_format_date('{$time}',1)}T00:01:00+08:00</lastmod> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>{@}]]></tpl_default> </item>
如果你有论坛,可以再添加个:
<item> <name><![CDATA[sitemap_forum]]></name> <tpl_default><![CDATA[{@} <url> <loc>http://seeble.cn/{$baseurl}?type=detail&sid={$sid}&tid={$id}</loc> <lastmod>{$=ii_format_date('{$time}',1)}T00:01:00+08:00</lastmod> <changefreq>weekly</changefreq> <priority>0.9</priority> </url>{@}]]></tpl_default> </item>
步骤 二
在 common/incfiles/module_config.inc.php 进行修改,用以下代码代替原来的:
<?php function jtb_cms_module_index() { $tmpstr = ii_ireplace('module.index', 'tpl'); return $tmpstr; }
function jtb_cms_module_sitemap() { $tmpstr = ii_ireplace('module.sitemap', 'tpl'); return $tmpstr; }
function jtb_cms_module() { switch($_GET['type']) { case 'sitemap.xml': return jtb_cms_module_sitemap(); break; case 'index': return jtb_cms_module_index(); break; default: return jtb_cms_module_index(); break; } } ?>
步骤 三
在网站首页的模板中添加一个新节点,内容如下:
<item> <name><![CDATA[sitemap]]></name> <tpl_default><![CDATA[<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">{$=vv_itransfer('top', 'sitemap', 'topx=10000;genre=article)} </urlset>]]></tpl_default> </item>
注意要把网址改成你自己的!
现在向Google提交就可以了,地址是:
http://seeble.cn/?type=sitemap.xml
|