Creating RSS Feeds in Codeigniter
Creating an RSS Feed with Codeigniter is our discussion this time.
Every website should have an RSS Feed, this is useful so that other people can take the news that is on our website to be displayed on their website, the content can be entire articles, or only pieces of articles.
In addition to being displayed on visitors’ websites, RSS Feeds are also useful if website visitors want to subscribe to the latest articles from our website through Google Reader, or applications on their cellphones.
If we use a CMS such as WordPress, Drupal or Joomla, usually the RSS Feed is already available, for example for our favorite website the RSS Feed address is located in DOMAIN/feed.
However, if we create a website without the help of the CMS that we mentioned above, then we must generate the RSS Feed manually.
We assume we create a website using the Codeigniter Framework (we assume you already understand the basics of MVC in Codeigniter), then the steps are something like this:
We take a few articles in our posting table, usually 10 articles are enough. We load the article in the model, then we parse the data from the Controller to the View in XML (not HTML). Examples are as follows.
Creating Databases and Tables
Create a database with the name you want, then create a table with the name tbl_posts, the structure is as follows:
post_id int(5) NOT NULL AUTO_INCREMENT,
post_title varchar(100) NOT NULL,
slug varchar(255) NOT NULL,
post_content longtext NOT NULL,
post_img varchar(100) NOT NULL,
post_date datetime NOT NULL,
click int(10) NOT NULL,
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Enter some data, in this example you should enter 10 sample articles, you can also try the SQL file that we have prepared, the file that you can download at the end of this article
Create Controller (rss.php)
Leave a Reply