Skip to content

Instantly share code, notes, and snippets.

@yuya-matsushima
Created April 4, 2011 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuya-matsushima/901108 to your computer and use it in GitHub Desktop.
Save yuya-matsushima/901108 to your computer and use it in GitHub Desktop.
seezoo1.0.1のfeed配信用アクションの追加
<?php
/**
* RSS2.0/RSS1.0/Atom feed配信
* @access public
* @params string
*/
function feed($mode = 'rss2')
{
$site_title = $this->init_model->get_site_info()->site_title;
$blog_title = $this->blog_model->get_blog_info()->page_title;
$blog_meta = $this->blog_model->get_blog_meta()->meta_description;
// サイト名とページ名からfeed用サイト名を作る
$site_info['site_title'] = ( ! empty($blog_title) ? $blog_title . ' :: ' : '') . $site_title;
$site_info['description'] = ( ! empty($blog_meta)) ? $blog_meta : '';
// blogデータをfeed生成用メソッド用に加工
$entries = $this->blog_model->get_recent_entry($this->blog_info->entry_limit);
$category_list = $this->blog_model->get_category_array();
foreach($entries as $entry)
{
$item[] = array(
'title' => $entry->title,
'url' => site_url('blog/article/' . $entry->sz_blog_id),
'description' => $entry->body,
'author' => '', // AuthorName
'date' => $entry->entry_date,
'category' => (array_key_exists($entry->sz_blog_category_id, $category_list)) ? prep_str($category_list[$entry->sz_blog_category_id]) : 'default'
);
}
if($mode == 'atom')
{
$type = 'A';
}
elseif($mode == 'rss1')
{
$type = 1;
}
else
{
$type = 2;
}
$this->load->library('rss');
$this->rss->output_rss($type, $item, $site_info);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment