اگه می تونی کدت رو بذار که بشه بررسی کرد.
این روش رو هم امتحان کن
1 - کنترلر فید
<?php
class Feed extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('posts_model', '', TRUE);
$this->load->helper('xml');
}
function index()
{
$data['encoding'] = 'utf-8';
$data['feed_name'] = 'webdesignermag.ir';
$data['feed_url'] = 'http://www.webdesignermag.com';
$data['page_description'] = 'نخستین نشریه تخصصی طراحی وب به زبان پارسی';
$data['page_language'] = 'fa-IR';
$data['creator_email'] = '';
$data['posts'] = $this->posts_model->getRecentPosts();
header("Content-Type: application/rss+xml");
$this->load->view('feed/rss', $data);
}
}
?>
چیزی که اینجا مهم هست اینه که content-type درست ست کنید
احتمالا یک تابع هم شبیه این توی مدل دارید:
function getRecentPosts ()
{
$this->db->orderby('post_date', 'desc');
$this->db->where('post_visible', 1);
$this->db->limit(10);
return $this->db->get('posts');
}
View رو هم می تونید اینطور بنویسید:
<?php
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>
<rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title><?php echo $feed_name; ?></title>
<link><?php echo $feed_url; ?></link>
<description><?php echo $page_description; ?></description>
<dc:language><?php echo $page_language; ?></dc:language>
<dc:creator><?php echo $creator_email; ?></dc:creator>
<dc:rights>Copyright <?php echo gmdate("Y", time()); ?></dc:rights>
<admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
<?php foreach($posts->result() as $entry): ?>
<item>
<title><?php echo xml_convert($entry->post_title); ?></title>
<link><?php echo site_url('blog/post/' . $entry->url_title) ?></link>
<guid><?php echo site_url('blog/post/' . $entry->url_title) ?></guid>
<description><![CDATA[
<?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $entry->post_body); ?>
]]></description>
<pubDate><?php echo date ('r', $entry->post_date);?></pubDate>
</item>
<?php endforeach; ?>
</channel></rss>
این خط کد هم همونطور که ازش مشخصه آدرس تصویر ها رو مطلق میکنه.
<?= str_replace('/img/post_resources/', base_url() . 'img/post_resources/', $entry->post_body); ?>
دقت کنید که URL helper رو حتما لود کرده باشید.