• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Truble, building RSS

#1
[eluser]iniweb[/eluser]
This is my code:

Code:
class Rss extends Controller {

    function Rss()
    {
        parent::Controller();

        $this->load->helper('date');
    }

    function Index()
    {
        $query = $this->db->query("SELECT * FROM ci_news WHERE status = '1' ORDER BY id DESC LIMIT 10");

        $content = '';

        foreach($query->result() as $row)
        {
            $row->date = human_to_unix($row->date);
            $row->date = standard_date('DATE_RSS', $row->date);
            $row->link = "<a href=\"http://yaba.ru/News/$row->id/\">http://yaba.ru/News/$row->id/</a>";

            $data = array(
                           'author'      => $row->author,
                           'title'       => $row->title,
                           'link'        => $row->link,
                           'images'      => $row->images,
                           'date'        => $row->date,
                           'short_story' => $row->short_story
                     );

            $content .= $this->parser->parse('Rss_Elements.tpl', $data);
        }

        $data = array(
                       'content'    => $content,
                 );

        $this->load->library('parser');
        $this->parser->parse('Rss.tpl', $data);
    }
}

if Rss.tpl have this content:

Code:
&lt;?xml version="1.0" encoding="windows-1251"?&gt;
&lt;rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"&gt;
<channel>
&lt;title&gt;Yaba News&lt;/title&gt;
&lt;link&gt;http://yaba.ru&lt;/link&gt;
<language>ru</language>
<description>Yaba News</description>
<generator>Yaba News</generator>

{content}

</channel></rss>

Show this error:

Quote:Parse error: parse error, unexpected T_STRING in x:\home\igniter.by\www\system\application\views\Rss.tpl on line 1

How to correct?

#2
[eluser]mironcho[/eluser]
Hi,
change first line in Rss.tpl to:

Code:
&lt;?php echo '&lt;?xml version="1.0" encoding="windows-1251"?&gt;' . "\n"; ?&gt;

And take a look at:

http://www.derekallard.com/blog/post/bui...e-igniter/

#3
[eluser]nirbhab[/eluser]
This is due to wrong RSS encoding,
check this link:
http://en.wikipedia.org/wiki/RSS

&lt;?php
header('Content-Type: text/html; charset=utf-8', true);

echo '&lt;?xml version="1.0" encoding="utf-8"?'.'>';
echo '<rss version="2.0">';
//code///////
?&gt;
Please check the above URL, it would surely help you out.
Thankx for the URL dear


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.