首页 网站建设正文

dedecms5.7 生成百度地图sitemap和谷歌地图sitemap教程

piaodoo 网站建设 2020-05-06 21:30:42 1198 0 织梦教程

dedecms5.7 生成百度地图sitemap和谷歌地图sitemap教程

今天就研究了下怎么用织梦dedecms生成正确的sitemap文件 。

织梦dedecms生成百度地图 。

好了 直接看步骤吧 。

1.dedecms 生成里面有一个生成地图,原来这个生成的是html,不是我们想要的,而且只生成栏目的,没文章,但是这个界面我们可以方便操作,所以就在这上面来进行修改 。

2.在 /templets/plus 目录下 找到两个文件sitemap.htm 和 rssmap.htm,前者我们当中是百度的sitemap 后者我们当中谷歌的sitemap 

3. 

修改sitemap.htm :把原来的代码全部删除 然后用下面的代码 。

<?xml version="1.0" encoding="{dede:global.cfg_soft_lang /}"?>

 

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 

 

<url> 

 

<loc>{dede:global.cfg_basehost/}</loc> 

 

<changefreq>always</changefreq> 

 

<priority>1.0</priority> 

 

</url> 

{dede:arclist row='10000' orderby='pubdate'}

<url> 

 

<loc>[field:global.cfg_basehost/][field:arcurl/]</loc> 

 

<lastmod>[field:pubdate function="GetDateMK(@me)"/]</lastmod> 

</url> 

{/dede:arclist} 

{dede:channelartlist row='50'}

 

<url>

 

<loc>{dede:global.cfg_basehost/}{dede:field name='typeurl'/}</loc>

 

<lastmod>{dede:php}echo date('Y-m-d');{/dede:php}</lastmod>

 

</url>

 

{dede:channel type='son' row='8'}

 

<url>

 

<loc>[field:global.cfg_basehost/][field:typelink/]</loc>

 

<lastmod>[field:id runphp="yes"]@me=date('Y-m-d');[/field:id]</lastmod>

 

</url>

 

{/dede:channel}

 

{/dede:channelartlist}

</urlset>

 

修改rssmap.htm:把原来的代码全部删除 然后用下面的代码

 

 

<?xml version='1.0' encoding='UTF-8'?>

 

 

<urlset xmlns='http://www.google.com/schemas/sitemap/0.84'>

 

 

 

{dede:arclist typeid='0' } 

 

 

 

 

<url><loc>[field:global.cfg_basehost/][field:arcurl/]</loc><lastmod>[field:pubdate function="MyDate('Y-m-d',@me)"/]</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>

 

 

 

{/dede:arclist}

 

 

 

{dede:channelartlist row=50}

 

 

 

 

<url><loc>{dede:global.cfg_basehost/}{dede:field name='typeurl'/}</loc><lastmod>{dede:php}echo date('Y-m-d');{/dede:php}</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>

 

 

 

 

 

 

{dede:channel type='son' row='8'}

 

 

 

 

<url><loc>[field:global.cfg_basehost/][field:typelink/]</loc><lastmod>[field:id runphp="yes"]@me=date('Y-m-d');[/field:id]</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>

{/dede:channel}

{/dede:channelartlist}

</urlset>

大家也可以自行修改条数

4.重点 

之前我就是这个地方有问题,一直生成不了数据,后来改了一些方法调用才OK

找到dede后台目录 找到 makehtml_map.php 

修改

在上面引用文件的时候 加一句 :require_once DEDEINC.”/arc.partview.class.php”;

搜索 if($dopost==”site”)

然后把这个判断里面的代码替换掉:

if($dopost==”site”)

{

$murl = $cfg_cmspath.”/sitemap.xml”;

$tmpfile = $cfg_basedir.$cfg_templets_dir.”/plus/sitemap.htm”;

}else

{

$murl = $cfg_cmspath.”/rssmap.xml”;

$tmpfile = $cfg_basedir.$cfg_templets_dir.”/plus/rssmap.htm”;

}

(原因: 1.html改为xml 不用多说 格式问题 

 

 

2.把data去掉了,因为sitemap这样的文件放到根目录效果更好 )

//$dtp = new DedeTagParse();

//$dtp->LoadTemplet($tmpfile);

//$dtp->SaveTo($cfg_basedir.$murl);

把这3句话注释掉

在上面的判断下面加入

$pv = new PartView();

$pv->SetTemplet($tmpfile); //在这里修改你的谷歌地图模板路径,相对于模板目录

$pv->SaveToHtml($cfg_basedir.$murl); //生成文件名,保存在根目录


 

版权声明:

本站所有资源均为站长或网友整理自互联网或站长购买自互联网,站长无法分辨资源版权出自何处,所以不承担任何版权以及其他问题带来的法律责任,如有侵权或者其他问题请联系站长删除!站长QQ754403226 谢谢。

有关影视版权:本站只供百度云网盘资源,版权均属于影片公司所有,请在下载后24小时删除,切勿用于商业用途。本站所有资源信息均从互联网搜索而来,本站不对显示的内容承担责任,如您认为本站页面信息侵犯了您的权益,请附上版权证明邮件告知【754403226@qq.com】,在收到邮件后72小时内删除。本文链接:https://www.piaodoo.com/9810.html

评论

搜索