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> ...
随机推荐
- 03--理解HelloWorld结构
作为程序猿还是要代码来说事的,现在开始进入到具体的代码中来.国际惯例HelloWorld打头阵,我也不能免这个俗. Win32入口函数中主要代码如下: main.cpp // 创建应用实例 AppDe ...
- JS对象排序
function createComparisonFunction(propertyName) {return function(object1, object2){var value1 = obje ...
- 在Win8.1(64位)系统上安装Scrapy(python 2.7.7)
为了在win8.1上安装scrapy折腾了好久,最终安装成功,总结步骤如下: 下载安装Visual C++ 2008 redistributables 安装lxml-3.2.4.win-amd64-p ...
- 函数:我的地盘听我的 - 零基础入门学习Python019
函数:我的地盘听我的 让编程改变世界 Change the world by program 函数与过程 在小甲鱼另一个实践性超强的编程视频教学<零基础入门学习Delphi>中,我们谈到了 ...
- 根据identifier从StoryBoard中获取对象,UIButton的图片文件位置
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- 利用Azure Redis Cache构建百万量级缓存读写
Redis是一个非常流行的基于内存的,低延迟,高吞吐量的key/value数据存储,被广泛用于数据库缓存,session的管理,热数据高速访问,甚至作为数据库方式提高应用程序可扩展性,吞吐量,和实施处 ...
- 使用ARM和VMSS创建自动扩展的web集群
在很多的商业场景中,用户的访问,峰值时间都是很难预测的,尤其是做一些市场推广活动和促销的时候,到底部署什么规模的web集群合适,这一直是个问题,部署过量会造成高成本和资源不必要的浪费,部署过少,如果到 ...
- 使用CURL发彩信,短信和进行多线程
短彩信发送 01 $xml_data = '<?xml version="1.0" encoding="UTF-8" standalone="y ...
- BZOJ 1264 基因匹配Match(LCS转化LIS)
题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=1264 题意:给出两个数列,每个数列的长度为5n,其中1-n每个数字各出现5次.求两个数列 ...
- 蓝牙芯片NRF51822入门学习1:时间管理
前言 之前辞职找工作的时候发现,很多公司希望招聘蓝牙技术方面的人才,所以干脆丢开LWIP静下心来学习蓝牙技术.原本以为一两星期能基本学会的,谁知道所选的蓝牙芯片nrf51822是个坑货,坑了我一个月. ...