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> ...
随机推荐
- 微信JS-SDK 接口调用与 php 遇到的坑
问题:config:invalid signature一直爆这个错误 解决: 看我把这些坑都总结了一下:要命的invalid signature. https://segmentfault.com/q ...
- 自定义View—绘制基本图形
一.Canvas能够绘制哪些图形 二.
- libevent使用之安装(一)
1.下载安装包,在官网http://www.monkey.org/~provos/libevent/下载 2.解压 运行命令: tar zxvf libevent-2.0.10-stable.tar. ...
- js实现选项卡切换的三种方式
前两种主要实现一个选项卡的切换,第三种使用闭包看书,构造函数实现多个选项卡的切换: 1.第一种实现实现效果为: 实现代码为: <!doctype html> <!DOCTYPE ht ...
- c# 大量拼接xml时内存溢出解决方法
public static string SelectUNnormalPriceSTrans(EUNnormalPriceS rqInfo) { string guidStrJianJclFirst ...
- 使用filter统一设置编码
1.写一个类EncodingFilter.java,实现javax.servlet.Filter(文件命名做到见名知意) package com.filter; import java.io.IOEx ...
- 【转】ios开发之生成所缩略图方式
亲测:两种方式都有效 第一种方式:缩略成固定的尺寸大小 - (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSiz ...
- AFNetworking了解
AFNetworking了解 AFNetworking是一个讨人喜欢的网络库,适用于iOS以及Mac OS X. 它构建于在NSURLConnection, NSOperation, 以及其他熟悉 ...
- mysql 导出导入sql
>mysqldump -u用户名 -p密码 -h主机名 数据库名 > 20150116mw_pm_db.sql mysql> source /home/y/my_work/20150 ...
- hdu 1596 find the safest road
http://acm.hdu.edu.cn/showproblem.php?pid=1596 #include <cstdio> #include <cstring> #inc ...