sitemap.xml 静态和动态生成页面 shopnc二次开发 动态生成sitemap.xml
Sitemap 可方便网站管理员通知搜索引擎他们网站上有哪些可供抓取的网页。最简单的 Sitemap 形式,就是XML 文件,在其中列出网站中的网址以及关于每个网址的其他元数据(上次更新的时间、更改的频率以及相对于网站上其他网址的重要程度为何等),以便搜索引擎可以更加智能地抓取网站。
目前有两种格式
一.Google SiteMap
<urlset xmlns=“网页列表地址”>
<url>
<loc>网址</loc>
<lastmod>2005-06-03T04:20-08:00</lastmod>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>网址</loc>
<lastmod>2005-06-02T20:20:36Z</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
Google SiteMap
二.百度sitemap
<?xml version="1.0" encoding="UTF-8"?>
<urlset>
<url>
<loc>网页地址</loc>
<lastmod>2010-01-01</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>
</urlset>
百度sitemap
XML标签
生成方法
1.静态在线生成Sitemap网站的网址
新建一个文本文件把代码粘贴进去,然后另存为utf-8格式的文件,文件名为sitemap.xml,然后把这个文件上传到自己网站的对应的根目录下面;
2.若要商城生成动态的sitemap 例如
某东www.jd.com/sitemap.xml
如果是一般商城的,可以从date.php(定时更新页面)入手
shopnc
/**
* 生成sitemap.xml文件
* @return [type] [description]
*/
function _create_sitemap(){
//首页
$index = "<url>";
$index .= "<loc>".SHOP_SITE_URL."</loc>";
$index .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$index .= "<changefreq>always</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$index .= "<priority>1.0</priority>"; //优先权 此值定于0.0 - 1.0之间
$index .= "</url>";
//登录页面
$index .= "<url>";
$index .= "<loc>".SHOP_SITE_URL.DS."index.php?act=login</loc>";
$index .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$index .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$index .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$index .= "</url>";
//注册页面
$index .= "<url>";
$index .= "<loc>".SHOP_SITE_URL.DS."index.php?act=login&op=register</loc>";
$index .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$index .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$index .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$index .= "</url>";
//app下载页面
$index .= "<url>";
$index .= "<loc>".BASE_SITE_URL.DS."app/index.html</loc>";
$index .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$index .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$index .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$index .= "</url>";
//商品分类
$goods_class = Model("goods_class")->getGoodsClassList(array("gc_show"=>1), "gc_id, gc_name");
$gc = "";
foreach($goods_class as $val){
$gc .= "<url>";
$gc .= "<loc>".urlShop("search","index",array("cate_id"=>$val["gc_id"]))."</loc>";
$gc .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$gc .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$gc .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$gc .= "</url>";
}
//设计师
$designer_list = Model("designer")->getDesignerList(array("designer_status"=>1), "designer_id, designer_name");
$dl = "";
foreach($designer_list as $val){
$dl .= "<url>";
$dl .= "<loc>".urlDesigner("designer","index",array("d_id"=>$val["designer_id"]))."</loc>";
$dl .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$dl .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$dl .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$dl .= "</url>";
}
//设计师资讯
$dnews_list = Model("dnews")->getArticleList(array(), 0);
$dn = "";
foreach ($dnews_list as $val) {
$dn .= "<url>";
$dn .= "<loc>".urlDnews("dnews","detail",array("dnews_id"=>$val["dnews_id"]))."</loc>";
$dn .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$dn .= "<changefreq>weekly</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$dn .= "<priority>0.9</priority>"; //优先权 此值定于0.0 - 1.0之间
$dn .= "</url>";
} //商品列表
$goods_list = Model("goods")->getGoodsOnlineList(array(), "goods_id, goods_name", 0, "goods_id desc", 5000);
$gl = "";
foreach($goods_list as $val){
$gl .= "<url>";
$gl .= "<loc>".urlShop("goods","index",array("goods_id"=>$val["goods_id"]))."</loc>";
$gl .= "<lastmod>". date("Y-m-d")."</lastmod>";//最后更新日期
$gl .= "<changefreq>daily</changefreq>";//更新频率 可选"always", "hourly", "daily", "weekly", "monthly", "yearly"
$gl .= "<priority>0.8</priority>"; //优先权 此值定于0.0 - 1.0之间
$gl .= "</url>";
}
$str = '<?xml version="1.0" encoding="utf-8"?>'."<urlset>".$index.$gc.$dl.$dn.$gl."</urlset>";
@file_put_contents(BASE_ROOT_PATH.DS."sitemap.xml", $str);
}
sitemap.xml 静态和动态生成页面 shopnc二次开发 动态生成sitemap.xml的更多相关文章
- shopnc二次开发(二)
一般来说二次开发,多数就是修改界面和增加功能这两个需求 先说修改界面 mvc 架构的程序,在界面这里,基本就是调用数据. 常见的界面数据构架有三种 1.是业务端或者是控制端数据驱动界面,基本上是后台输 ...
- 基于Django+celery二次开发动态配置定时任务 ( 一 )
需求: 前端时间由于开发新上线一大批系统,上完之后没有配套的报表系统.监控,于是乎开发.测试.产品.运营.业务部.财务等等各个部门就跟那饥渴的饿狼一样需要 各种各样的系统数据满足他们.刚开始一天一个还 ...
- shopnc二次开发(一)
---恢复内容开始--- 以前没有怎么接触过shopnc,感觉界面挺漂亮的,不过后来自己需要开发一个电商系统,就顺便参考了下,感觉构架垃圾的一塌糊涂.不过平时做这个系统二次开发的业务比较多,所以简单的 ...
- appium-desktop录制脚本二次开发,生成我司自动化脚本
目的 通过对appium-desktop脚本录制功能进行二次开发,使录制的java脚本符合我司自动化框架要求. 实现步骤 1.增加元素名称的输入框 由于ATK(我司自动化测试框架)脚本中元素是以“ap ...
- Harbor 定制页面 和 二次开发指南
harbor的官方地址:https://github.com/goharbor/harbor 想对Harbor进行二次开发,首先要指定一个harbor的版本,这里我们以Harbor:1.6.2为例: ...
- 基于Django+celery二次开发动态配置定时任务 ( 二)
一.需求 结合上一篇,使用djcelery模块开发定时任务时,定时任务的参数都保存在djcelery_periodictask表的args.kwargs字段里,并且是json格式.那么,当定时任务多了 ...
- shopnc 二次开发问题(一)
1.关于shopnc商品详情页面多规格抢购,价格显示都是显示的抢购价格问题 路径: data/model/groupbuy.model.php 方法:getGroupbuyInfoByGoodsCom ...
- 动态代理学习(二)JDK动态代理源码分析
上篇文章我们学习了如何自己实现一个动态代理,这篇文章我们从源码角度来分析下JDK的动态代理 先看一个Demo: public class MyInvocationHandler implements ...
- shopnc 二次开发 每日签到积分领取
/* 开始shopnc!!!!! url:xxx.com/index.php?act=index&op=userjf 一个四线城市的半吊子程序员~ 实现:前台模板文件 随便加入<a> ...
随机推荐
- Double Strings Solved Problem code: DOUBLE
# Fuking silly, OTZ.... import sys def main(): n = int(raw_input()) for num in sys.stdin: if int(num ...
- Linux配置完iptables后,重启失效的解决方案
Linux配置完iptables后,重启失效的解决方案 因为只有root用户才可访问1024以下的端口,非root用户登陆是不能启用80端口的.web service 往往启动1024以上的端口,并通 ...
- 【转】Linux下tar.xz结尾的文件的解压方法--不错
原文网址:http://blog.csdn.net/silvervi/article/details/6325698 今天尝试编译内核,下载到了一份tar.xz结尾的压缩文件,网上解决方法比较少,不过 ...
- bzoj1379 [Baltic2001]Postman
Description 邮递员每天给N个村子的人送信,每个村子可能在某个十字路口上,或一条路的中央. 村子里的人都希望早点收到信,因此与邮递员达成一个协议:每个村子都有一个期望值Wi,如果这个村子是邮 ...
- poj1552
Doubles Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18824 Accepted: 10846 Descrip ...
- IOS Main函数
int main(int argc, char * argv[]) { @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSS ...
- Block 代替for循环
NSDictionary *aDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:", nil]; [aDictionary e ...
- iTunes 重新提交代码步骤
1.选择View Details 2.右侧Links-Binary Details选项 3.Reject This Binary
- Java客户端Jedis的八种调用方式
redis是一个著名的key-value存储系统,而作为其官方推荐的java版客户端jedis也非常强大和稳定,支持事务.管道及有jedis自身实现的分布式. 在这里对jedis关于事务.管道和分 ...
- Atitit. 最佳实践 QA----减少cpu占有率--cpu占用太高怎么办
Atitit. 最佳实践 QA----减少cpu占有率--cpu占用太高怎么办 跟个磁盘队列长度雅十,一到李80%走不行兰.... 1. 寻找线程too 多的.关闭... Taskman>> ...