dedecms制作xml格式的網(wǎng)站地圖做法

字號:


    第一步:打開/dede/inc/inc_menu.php和/dede/inc/inc_menu_map.php文件,找到 <m:item name='更新主頁HTML' link='makehtml_homepage.php' rank='sys_MakeHtml' target='main' /> 這一句并復(fù)制一句,修改為:
    <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);這段代碼,將其注釋或者直接刪除,底部修改調(diào)用生成文件模板為makehtml_sitemap.htm,然后另存為makehtml_sitemap.php,上傳至dede/即可。
    第三步:制作后臺更新模板文件dede/templets/makehtml_sitemap.htm
    直接拷貝一個dede/templets/makehtml_homepage.htm文件,找到<input name="templet" type="text" id="templet"<?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"default/sitemap.xml">【注:default為織夢默認(rèn)模板存放文件夾,如果你把網(wǎng)站模板單獨(dú)放在另一個文件夾,這里的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
    將以下代碼復(fù)制粘貼到記事本里,修改記事本名稱為:sitemap.xml即可
    <?xml version="1.0" encoding="gb2312"?>
    <?xml-stylesheet type="text/xsl" href="/templets/css/sitemap.xsl"?><!-- generator="dedecms/3.2" -->
    <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
    <url>
    <loc>http://www.software8.co</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文件,我會單獨(dú)放一個頁面中。sitemap.xsl文件主要是把xml格式的內(nèi)容轉(zhuǎn)換成具有一定樣式的內(nèi)容,這個文件引用的時候注意下文件所放位置,否則會顯示錯誤。