0
votes

How to display daily news update in core PHP web site auto posting ? Core php web site Showing RSS Feed On Page

I have a requirement to show an RSS feed from a third party site. I don't want to do this through the browser's RSS mechanism. Instead I want to embed the feed (with styling) into a particular page.

My question is, can this be done just using the CMS admin? Is there a particular content type/part I can use? Or would this have to be done programatically?

I realise there are modules that I could download, but I see no support for RSS feeds for , which I'm using. The ones I've tried are for later versions.

http://www.cnplus.co.uk/XmlServers/navsectionRSS.aspx?navsectioncode=12911

http://www.anglianwater.co.uk/_assets/media/xml/rss-news.xml

3

3 Answers

1
votes

If you are using WOrdpress CMS tool then it would be easy to integrate the RSS feed onto your page.

Checkout https://wordpress.org/plugins/tags/rss-feed for plugins. I personally recommend https://wordpress.org/plugins/wp-rss-aggregator/ plugin as this is one of the best RSS plugin i have come accross.

0
votes

There are 2 ways to do this:

  1. Only load the content of the 3rd party feed inside the HTML documents using Javascript. This means that you will not "store" or "cache" the content from your servers... but that you will load content from a 3rd party site/application.
  2. Store the content of the RSS feed in your backend and load it like the rest of your HTML documents using PHP. To the frontend, the content from the RSS feeds will then be exactly like the rest of your content.

This blog posts shows how to use the Superfeedr API with either approach.

0
votes

$mypix = simplexml_load_file('http://www.anglianwater.co.uk/_assets/media/xml/rss-news.xml');

$i=0; foreach ($mypix->channel->item as $pixinfo)

{
    $title=$pixinfo->title;
    $link=$pixinfo->link;
    $description=$pixinfo->description;
    $pubdate=$pixinfo->pubDate;
  // $image=str_replace("_b.jpg","_s.jpg",$pixinfo->link[1]['href']);
    $title=strip_tags($title, '<br>');
   $link=htmlspecialchars($link);
     $description=strip_tags($description, '<br>');
     $pubdate=strip_tags($pubdate, '<br>');

    echo '<div class="row">
            <div class="box-sizing" style="border:1px; border-color:blue;">
                <p class="large text-muted">'.$title.'</p>
                <p class="large text-muted">'.$description.'</p>
                <p class="large text-muted">'.$pubdate.'</p>
            </div>
        </div>';

     if (++$i == 3) break;      

} 

Put above code in "php code"

if you get

rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0"

type xml

chnge $pubdate=$pixinfo->pubDate

insted of

$pubdate=$pixinfo->children('http://www.w3.org/2005/Atom')->updated;