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> ...
随机推荐
- linux常用命令(6)mv命令
mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files),是Linux系统下常用的命令,经常用来备份文件或者目录.1 命令格式:mv [选项] 原文件或目录 ...
- hdu 2807 The Shortest Path
http://acm.hdu.edu.cn/showproblem.php?pid=2807 第一次做矩阵乘法,没有优化超时,看了别人的优化的矩阵乘法,就过了. #include <cstdio ...
- 《Programming WPF》翻译 第9章 3.自定义功能
原文:<Programming WPF>翻译 第9章 3.自定义功能 一旦你挑选好一个基类,你将要为你的控件设计一个API.大部分WPF元素提供属性暴露了多数功能,事件,命令,因为他们从框 ...
- 阵列卡,组成的磁盘组就像是一个硬盘,pci-e扩展出sata3.0
你想提升性能,那么组RAID0,主板上的RAID应该是软RAID,肯定没有阵列卡来得稳定.如果你有闲钱,可以考虑用阵列卡. 不会的.即使不能起到RAID的作用,起码也可以当作直接连接了2个硬盘.不会影 ...
- 107个常用Javascript语句
1.document.write( " "); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document- >html- >(head,body ...
- 【剑指offer】面试题34:丑数
题目: 把只包含因子2.3和5的数称作丑数(Ugly Number).例如6.8都是丑数,但14不是,因为它包含因子7. 习惯上我们把1当做是第一个丑数.求按从小到大的顺序的第N个丑数. 思路: 第一 ...
- Find the Duplicate Number 解答
Question Given an array nums containing n + 1 integers where each integer is between 1 and n (inclus ...
- Hive 5、Hive 的数据类型 和 DDL Data Definition Language)
官方帮助文档:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL Hive的数据类型 -- 扩展数据类型data_t ...
- 第10讲- UI线程阻塞及其优化
第10讲UI线程阻塞及其优化 .UI 阻塞demo (首先在activity_main.xml中放置两个button,分别命名为button1,button2) //首先设置一个button1用来进行 ...
- C#中,表达式的计算遵循一个规律:从左到右依次计算。
int i = 0; int j = (i++)+(i++)=(i++)+i=i+++i=i+++i++=1;