Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Codeigniter的RSS提要_Php_Codeigniter_Rss - Fatal编程技术网

Php 使用Codeigniter的RSS提要

Php 使用Codeigniter的RSS提要,php,codeigniter,rss,Php,Codeigniter,Rss,我使用Codeigniter创建了一个RSS提要,下面是来自 但是我的问题是,提要内容没有显示在页面上,但是如果您浏览html源代码,它是可用的 这是我的控制器代码: public function __construct() { parent::__construct(); $this->load->model('articles_model'); $this->load->helper('xml'); $this->

我使用Codeigniter创建了一个RSS提要,下面是来自

但是我的问题是,提要内容没有显示在页面上,但是如果您浏览html源代码,它是可用的

这是我的控制器代码:

public function __construct()
{
    parent::__construct();        
    $this->load->model('articles_model');
    $this->load->helper('xml');
    $this->load->helper('text');
}

public function index()
{
    $data['feed_name'] = 'MyDebut.ph'; 
    $data['encoding'] = 'utf-8'; 
    $data['feed_url'] = 'http://www.mydebut.com/feeds'; 
    $data['page_description'] = 'Everything for turning 18.'; 
    $data['page_language'] = 'en-en'; 
    $data['creator_email'] = 'mydebutph@gmail.com'; 
    $data['posts'] = $this->articles_model->getArticlesPaginated(0,30); 


    header("Content-type: text/xml; charset=utf-8");

    $this->load->view('rss', $data);
}
我的视图代码:

    <?php echo '<?xml version="1.0" encoding="' . $encoding . '"?>' . "\n"; ?>
<rss version="2.0">
    <channel>
        <title><?php echo $feed_name; ?></title>
        <description><?php echo $page_description; ?></description>
        <link><?php echo $feed_url; ?></link>
            <?php foreach ($posts as $post): ?>
            <item>
              <title><?php echo xml_convert($post['art_title']); ?></title>
              <link><?php echo base_url().'blogs/'.$post['sec_slug'].'/'.$post['cat_slug'].'/'.$post['art_slug'];?>
              <description><?php echo character_limiter($post['art_sub'], 300); ?></description>
            </item>
        <?php endforeach; ?>
    </channel>
</rss>

查看缓冲区 确保通过将true作为第三个参数来设置缓冲区(视图为字符串)


输出类 可以使用输出类将缓冲区(而不是视图本身)直接发送到浏览器


使用适当的元属性
我不知道您的模型代码中有什么,但据我所知,在控制器中,您没有从模型中获得结果数组。检查rss视图的22行

    <?php foreach($posts->result() as $post): ?>

同时检查文档,也许可以帮助您

$this->output->set_content_type('application/rss+xml')->set_output(file_get_contents($view));
<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/">
<link rel="alternate" type="application/rss=xml" title="Blog Feed" href="<?php echo site_url('rss'); ?> "/>
    <?php foreach($posts->result() as $post): ?>