cms增加定时更新网站地图

发布于:2024-04-28 ⋅ 阅读:(19) ⋅ 点赞:(0)

1.先进入ftp,进入后找到模板目录内-
2.新建模板-文件名ceshi.htm-粘贴下面内容进去(注意域名更改)

<?xml version="1.0" encoding="utf-8"?>
<urlset>
	<url>
		<loc>{dede:global.cfg_basehost/}/index.html</loc>
		<priority>1.0</priority>
		<changefreq>Always</changefreq>
	</url>
{dede:tag  row='14' sort='month' getall='1' } 
	<url>
	    <loc>[field:global.cfg_basehost/][field:id function="nic_tag_url(@me)" /]</loc>
		<priority>0.8</priority>
		<changefreq>daily</changefreq>
	</url>
{/dede:tag}
{dede:arclist row=10000 orderby=pubdate }
	<url>
		<loc>[field:global.cfg_basehost/][field:arcurl/]</loc>
		<priority>0.6</priority>
		<changefreq>daily</changefreq>
		<lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>
	</url>
{/dede:arclist} 

</urlset>
3.打开include 打开taglib 
4.新建一个php文件 文件名随意(我这里是ceshi.php)粘贴下面的代码

<?PHP

//定时生成网站地图

require_once(dirname(__FILE__).'/../../include/common.inc.php');

include(DEDEINC."/arc.listview.class.php");

$lv = new ListView();

//解析模板到字符串

$lv->PartView = new PartView($lv->TypeID,false);

$lv->PartView->SetTypeLink($lv->TypeLink);

$lv->PartView->SetTemplet(DEDETEMPLATE.'/ceshi/ceshi.htm');

//上面的这个demo路径改成你自己刚新建的模板(ceshi.htm)的目录

$html = $lv->PartView->GetResult();

//生成文件sitemap.xml

file_put_contents('../../sitemap.xml',$html);

?> 

5.然后访问你刚才创建好的php http://域名/include/taglib/ceshi.php
6.返回文件根目录查看 是否生成一个sitemap.xml
7.在宝塔里增加定时任务,定时访问此url
``


网站公告

今日签到

点亮在社区的每一天
去签到