zoukankan      html  css  js  c++  java
  • 织梦后台如何生成站点地图sitemap.xml

    第一步在网站根目录建立sitemap.php文件

    内容如下:

    写一个计划任务文件命名为generate_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.'/2012/sitemap.xml');$html = $lv->PartView->GetResult();file_put_contents('./sitemap.xml',$html);?>

    第二步建立sitemap.xml文件

    首先在模板目录(网站目录/templets/default/sitemap.xml)放一个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=2000 orderby=pubdate}<url>    <loc>[field:arcurl/]</loc>    <lastmod>[field:pubdate function=strftime('%Y-%m-%d',@me)/]</lastmod>    <changefreq>monthly</changefreq></url>{/dede:arclist}</urlset>

    第三步生成xml文件

    如图所示:

    此时,你网站根目录下会产生一个sitemap.xml文件,此时可以访问:域名/sitemap.xml.

     OK! 定时生成网站地图(sitemap.xml)功能结束,你可以在百度站长平台里提交这个网站地图文件,百度robot会更喜欢你的网站!

  • 相关阅读:
    [ios]blocks
    [算法] 堆,栈 【转】
    [ios]关于内存错误调试
    [ios]get,post请求 【转】
    [ios]iOS模拟器应用程序目录结构
    [ios]iPhone地图应用开发以及自定义Annotation [转]
    [算法]插入排序
    [ios]让alertView 自动消失【转】
    [ios]延迟执行方法,取消执行方法
    [算法] 基数排序
  • 原文地址:https://www.cnblogs.com/fkcqwq/p/6994036.html
Copyright © 2011-2022 走看看