第一步、首先在模板目錄放一個sitemap.xml的模板文件,文件的內容如下:
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><url><loc>/</loc><lastmod>{dede:arclist row=1 titlelen=24 orderby=pubdate}[field:pubdate function=strftime('%Y-%m-%d',@me)/]{/dede:arclist}</lastmod><changefreq>daily</changefreq><priority>1.0</priority></url>{dede:channel row='10' type='top'}<url><loc>[field:typelink /]</loc><changefreq>daily</changefreq><priority>0.8</priority></url>{/dede:channel}{dede:arclist row=1000 orderby=pubdate}<url><loc>[field:arcurl/]</loc><lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod><changefreq>monthly</changefreq></url>{/dede:arclist}</urlset>
第二步、手動寫一個計劃任務執行文件,將該文件命名為CUOxin.com_sitemap.php,放在/plus/task目錄里,文件的內容如下:
<?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.'/CUOxin.com/sitemap.xml');$html = $lv->PartView->GetResult();file_put_contents('../../sitemap.xml',$html);?>
/CUOxin.com/sitemap.xml 是模板文件所目錄名稱,更換成自己的模板目錄即可。
第三步、在織夢后臺添加計劃任務,系統——計劃任務管理——增加新任務:
任務名稱:定時生成網站地圖
運行程序:CUOxin.com_sitemap.php
執行時間自己根據需要進行適當的設置
其它選項默認即可。
第四步、在模板目錄的foot.hml文件或其他公共模板include文件的body標簽結束之前加上代碼后生成全站即可。
添加完成后網站用戶在計劃任務規定的時間內瀏覽一下網頁就可以觸發計劃任務文件的執行,就可以自動生成一次sitemap.xml,如果上次運行時間的時間正常就證明定時任務執行成功了。



















