Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1004467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:08:20+00:00 2026-05-16T08:08:20+00:00

I run a small blog network and on this I have a page where

  • 0

I run a small blog network and on this I have a page where I show the latest blog posts from different blogs on my server. I would like to extend this page, to also include new posts from external blogs using rss feeds.

Currently it’s easy to get the content, since it’s just a simple query selecting posts by date, but it troubles me to see how to make the most effective design when extending it.

The easiest solution would be to periodic run a cronjob that import posts from the external sites, and then save them in the database. Though this creates the possibility that the posts could be altered in content or removed by the author, leaving me to display ”invalid content”.

The best solution would be if I don’t have to save the posts, and instead just import them directly on the page. But how would this affect usability and loading time? Is it somehow possible to cache the feeds? If I should choose a combination of displaying internal and external posts using a query and importing feeds directly, how can this be combined to use ”pagination” (10 results pr. page)?

I hope someone can help me with a small proof of concept code, or describe what they believe would be the most effective way of handling this.

PS: For importing feeds I use SimplePie http://simplepie.org

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:08:21+00:00Added an answer on May 16, 2026 at 8:08 am

    If you already use SimplePie then you can use its caching mechanism to have the feed data cached.

    To combine the articles from internal and external sources create a data structure with all articles. This can be an array of all items sorted by publication timestamp. Then from this array choose the articles for a certain page number.

    Here’s some code to create a combined array of posts. This should give you a idea of the steps involved. The Post class represents a post. The internal and external posts are converted to a Post and stored in the array $posts. This array is sorted by timestamp and at the end all posts are echoed.

    $internalPosts must contain the posts form your system and $feedUrls the URL’s of the external feeds. Since I don’t know the structure of the internal posts you must adapt the part where internal posts are converted to generic posts.

    $internalPosts = array();
    $feedUrls = array();
    
    include_once 'simplepie.inc';
    
    class Post {
        public $title;
        public $link;
        public $description;
        public $publishedAt;
    
        public function __construct($title, $link, $description, $publishedAt) {
            $this->title = $title;
            $this->link = $link;
            $this->description = $description;
            $this->publishedAt = $publishedAt;
        }   
    }
    
    $posts = array();
    
    // Convert internal posts to generic post.
    foreach($internalPosts as $item){
        $posts[] = new Post($item->title, $item->link, $item->description, $item->publishedAt);
    }
    
    // Retrieve feeds and add posts.
    $feed = new SimplePie();
    
    foreach($feedUrls as $url){
        $feed->set_feed_url($url);
        $feed->init();
    
        foreach ($feed->get_items() as $item) {
            $posts[] = new Post($item->get_title(), $item->get_link(), $item->get_description(), $item->get_date('U'));
        }
    }
    
    // Sort function.
    function byPublicationTimestamp($itemA, $itemB){
        return ($itemB->publishedAt - $itemA->publishedAt);
    }
    
    usort($posts, 'byPublicationTimestamp');
    
    foreach($posts as $post){
        echo "<p><a href='$post->link'>$post->title</a><br/>" . date('l, j F Y', $post->publishedAt) . " - $post->description</p>"; 
    }
    

    For improved performance consider storing the combined articles separately and build the pages from this data. Then you need to update this combined data anytime a new article is published internally or the cached version of an external feed has been refreshed.

    If you need to publish the external content shortly after it’s published on the original site then I would contact those sites to see if it’s possible to get a notification of updates instead of waiting for the cached version to expire.

    EDIT: added sample code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a small http proxy server on my machine which
So, I have followed this instruction from ADO.NET team blog to try to make
I have run into a small issue in my program. I have a class
Background: I'm building a small application that will be run daily, pulling data from
I am creating a small Yahtzee game and i have run into some regex
I am trying to run a small example which i found from here http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
Thanks for at least looking at this question. I run a small website which
I would like to run a small Windows program on an Android slate. It
I run an ASP.Net MVC3 application and have followed this Windows Azure How-To on
I would like to run a small PHP Code after the successful Registration. Means

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.