Welcome Guest, Not a member yet? Register   Sign In
RSS with CI 4.6
#1

Where can I find a simple example of RSS creation with CodeIgniter 4.6 I found example but it does not work cause old version. We should remove all 10 years old answers it is useless today
CodeIgniter 4.6
Reply
#2

(03-17-2025, 11:25 AM)cb21 Wrote: Where can I find a simple example of RSS creation with CodeIgniter 4.6 I found example but it does not work cause old version. We should remove all 10 years old answers it is useless today

Hi, i have make my own here: https://infinity-area.com/fr/rss


Code:
    /** ( EXAMPLE)
    * RSS Global
    */
    public function index()
    {
        $NewsModel         = new NewsModel();
        $news              = $NewsModel->GetNewsRss();

        $response          = $this->response;
        $response->setHeader('Content-Type', 'application/rss+xml; charset=UTF-8');
        return $response->setBody(view('front/themes/' . THEME . '/blog/rss', $news));
    }


Code:
<?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:media="http://search.yahoo.com/mrss/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:webfeeds="http://webfeeds.org/rss/1.0"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
    <channel>
        <title>WEBSITE TITLE</title>
        <link>WEBSITE URL</link>
        <description>WEBSITE DESCRIPTION</description>
        <atom:link href="rss.xml" rel="self"></atom:link>
        <webfeeds:logo>LOGO</webfeeds:logo>
        <image>
            <url>favicon_imageuri</url>
            <title>WEBSITE TITLE</title>
            <link>your_rss_pagelink</link>
        </image>
        <language>{{ global.locale }}</language>
        <lastBuildDate>{{ now|date('D, d M Y H:i:s O') }}</lastBuildDate>
        {% for article in news %}
            <item>
                <title>title_post</title>
                <link>link_to_post</link>
                <guid isPermaLink="true"> link_to_post</guid>
                <pubDate>date_here</pubDate>
                <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">author_name</dc:creator>
                <enclosure
                        url="picture_url"
                        length="1"
                        type="image/webp"
                        />
            </item>
        {% endfor %}
    </channel>
</rss>
Reply
#3

SimplePie- RSS Feed Reader.

SimplePie
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

Code:
Thank you it was a great model to start what I wanted to do.
CodeIgniter 4.6
Reply
#5

[quote pid="424731" dateline="1742253683"]
I have a problem
I got this message
syntax error, unexpected identifier "version"
Probably due to this line in my view
1 <?xml version="1.0" encoding="UTF-8" ?>
synt
[/quote]
CodeIgniter 4.6
Reply
#6

(03-25-2025, 11:01 AM)cb21 Wrote: [quote pid="424731" dateline="1742253683"]
I have a problem
I got this message
syntax error, unexpected identifier "version"
Probably due to this line in my view
1 <?xml version="1.0" encoding="UTF-8" ?>


I still have the same problem and did not find any solution

Is this line mandatory ? 
synt

[/quote]
CodeIgniter 4.6
Reply
#7

Can you try this?

PHP Code:
<?php
    
// try this in your view file.
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
?>
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB