服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > dedecms教程 >

dedecms制作xml格式的网站地图做法

时间:2016-12-17 13:05来源:未知 作者:最模板编辑 点击:
织梦dedecms制作xml格式的网站地图做法: 第一步:打开/dede/inc/inc_menu.php和/dede/inc/inc_menu_map.php文件,找到 m:item name=更新主页HTML link=makehtml_homepage.php rank=sys_MakeHtml target=main / 这一句并复制
织梦dedecms制作xml格式的网站地图做法:

第一步:打开/dede/inc/inc_menu.php和/dede/inc/inc_menu_map.php文件,找到 <m:item name='更新主页HTML' link='makehtml_homepage.php' rank='sys_MakeHtml' target='main' /> 这一句并复制一句,修改为:
<m:item name='更新Sitemap' link='makehtml_sitemap.php' rank='sys_MakeHtml' target='main' />
 
第二步:制作dede/makehtml_sitemap.php文件
 
直接拷贝一个dede/makehtml_homepage.php文件,找到$pv->SetTemplet($cfg_basedir.$cfg_templets_dir."/".$templet); $pv->SaveToHtml($homeFile);这段代码,将其注释或者直接删除,底部修改调用生成文件模板为makehtml_sitemap.htm,然后另存为makehtml_sitemap.php,上传至dede/即可。
 
第三步:制作后台更新模板文件dede/templets/makehtml_sitemap.htm
 
直接拷贝一个dede/templets/makehtml_homepage.htm文件,找到<input name="templet" type="text" id="templet" style="width:300″ value="<?php echo $row['templet']?>">和<td height="20″ valign="top" bgcolor="#FFFFFF"><input name="position" type="text" id="position" value="<?php echo $row['position']?>" size="30″> 这两段代码
 
分别修改为:<input name="templet" type="text" id="templet" style="width:300″ value="default/sitemap.xml">【注:default为织梦默认模板存放文件夹,如果你把网站模板单独放在另一个文件夹,这里的default就写你的模板存放文件夹】<td height="20″ valign="top" bgcolor="#FFFFFF"><input name="position" type="text" id="position" value="../sitemap.xml" size="30″>然后另存为makehtml_sitemap.htm,上传至dede/templets/;
 
第四步:制作sitemap模板文件 templets/sitemap.xml
将以下代码复制粘贴到记事本里,修改记事本名称为:sitemap.xml即可
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="/templets/css/sitemap.xsl"?><!-- generator="dedecms/3.2" -->
<urlset xmlns="
<url>
<loc>
<lastmod>
{dede:arclist row=1 titlelen=30 orderby=pubdate}
[field:pubdate function=strftime('%Y-%m-%d',@me)/]
{/dede:arclist}
</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
{dede:channel row='30' type='top'}
<url>
<loc>[field:typelink /]</loc>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
{/dede:channel}
{dede:arclist row=2000 orderby=pubdate}
<url>
<loc>[field:arcurl/]</loc>
<lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
{/dede:arclist}
</urlset>
 
注:<?xml-stylesheet type="text/xsl" href="/templets/css/sitemap.xsl"?> 这里的sitemap.xsl文件,我会单独放一个页面中。sitemap.xsl文件主要是把xml格式的内容转换成具有一定样式的内容,这个文件引用的时候注意下文件所放位置,否则会显示错误。
(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------