Codeigniter Rss,网站地图,路由配置
_ _,今天在成果不错,完成了网站的三个功能,RSS订阅,自动写网站地图,与路由的配置,好了,现在一 一记录下来.一、路由配置
在未设定路由时,路径是这样的
[php]
http://www.xiuxiandou.com/content/it/13533/硅谷传奇投资人讲述初创企业家易犯的4大错误
content =>controller,it=>method,13533=>id,硅谷传奇投资人讲述初创企业家易犯的4大错误=>title
http://www.xiuxiandou.com/content/it/13533/硅谷传奇投资人讲述初创企业家易犯的4大错误
content =>controller,it=>method,13533=>id,硅谷传奇投资人讲述初创企业家易犯的4大错误=>title
设置路由后,访问路径为:
[php]
http://www.xiuxiandou.com/content-it-13533-硅谷传奇投资人讲述初创企业家易犯的4大错误
http://www.xiuxiandou.com/content-it-13533-硅谷传奇投资人讲述初创企业家易犯的4大错误
其它的类似,路径配置为
[php]
/*sitemap使用*/
$route['content-(:any)-(:num)'] = "content/$1/$2";
/*前台页面显示路由*/
$route['content-(:any)-(:num)-(:any)'] = "content/$1/$2/$3";
/*RSS订阅路由*/
$route['feed-rss-(:any)'] = "feed/rss/$1";
/*博客路由*/
$route['blog-(:num)-(:any)'] = "blog/blogview/$1/$2";
$route['blog-blogtypes-(:any)']="blog/blogtypes/$1";
/**留言**/
$route['me'] = "indexs/me";
/**模板**/
$route["template"]="indexs/template";
/**今日更新**/
$route["indexs-(:any)"]="indexs/$1";
/*sitemap使用*/
$route['content-(:any)-(:num)'] = "content/$1/$2";
/*前台页面显示路由*/
$route['content-(:any)-(:num)-(:any)'] = "content/$1/$2/$3";
/*RSS订阅路由*/
$route['feed-rss-(:any)'] = "feed/rss/$1";
/*博客路由*/
$route['blog-(:num)-(:any)'] = "blog/blogview/$1/$2";
$route['blog-blogtypes-(:any)']="blog/blogtypes/$1";
/**留言**/
$route['me'] = "indexs/me";
/**模板**/
$route["template"]="indexs/template";
/**今日更新**/
$route["indexs-(:any)"]="indexs/$1";
二、RSS
在libraries目录下创建Rss.php文件,主要负责生成RSS格式的数据内容
[php]
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Rss
*/
class Rss{
public function write_rss($in_datas){
$CI=& get_instance();
$CI->load->helper('xml');
$CI->load->helper('text');
$xml_str="<?xml version='1.0' encoding='UTF-8'?>"
."<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:wfw='http://wellformedweb.org/CommentAPI/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:atom='http://www.w3.org/2005/Atom' xmlns:sy='http://purl.org/rss/1.0/modules/syndication/' xmlns:slash='http://purl.org/rss/1.0/modules/slash/' >";
if(!emptyempty($in_datas)){
$xml_str.="<channel>"
."<title>".$in_datas["feed_name"]."</title>"
."<atom:link href='".$in_datas["feed_url"]."' rel='self' type='application/rss+xml' />"
."<link>".$in_datas["feed_url"]."</link>"
."<description>".$in_datas["page_description"]."</description>"
."<language>zh-cn</language> "
."<sy:updateFrequency>1</sy:updateFrequency>"
."<sy:updatePeriod>hourly</sy:updatePeriod> "
."<dc:rights>Copyright (C) Xiuxiandou.com. All rights reserved.</dc:rights>"
."<generator>http://www.xiuxiandou.com</generator>";
if(!emptyempty($in_datas["xml_datas"])){
foreach($in_datas["xml_datas"] as $k => $v){
foreach($v as $xml){
$xml_str.=" <item>"
补充:Web开发 , php ,
- 更多php疑问解答:
- wordpress问题<?php if(have_posts()) : ?>
- 建设一个搜索类网站php还是jsp,数据库那个好
- 我是一个学PHP的,我现在已经学会了PHP,HTML,CSS,JS,JQ,AJAX,XML,thinkPHP,smarty模板
- 没理由啊 php代码无法执行,貌似有语法错误。。。
- 关于PHP 和API 的一段代码不懂啊不懂,请高手指点! 这是淘宝API的
- php语言中,序列化到底在那里使用?它的优势是什么?劣势是什么?
- PHP函数等于或等于应该怎么表达
- 请教php高手,解决basename函数和mb_substr函数处理中文文件名称的解决方法,在上传文件时,总是出现乱码
- .NET,PHP,JAVA,JS优秀点分别是?
- 织梦cms 在环境监测的时候 wamp5 gd不支持 是为什么。;extension=php_gd2.dll这一句我删除了还是不显示?
- 我想学PHP。1.应安装什么编程工具? 2. 装LIUNX系统是装简易的还是?什么版本的?3.还应安装什么?
- <?php 和 <? 有什么区别
- PHP网页如何接收按钮的值?请问
- 买来书的代码运行好是错误。。帮帮忙啊。php
- 求,一个php代码,用来修改 mysql数据库中的商品名字的大小写