Jump to content

Recommended Posts

Posted

I'm going to be building a real estate website soon and am exploring my options. The site will have some pages that will be native to PW, but all their property listing information will come from an XML feed from an external provider.

What's the best way to approach this? I've come across http://modules.processwire.com/modules/rss-feed-loader/ but is it possible to do searching, categorisation and pagination using that?

Or is there a better way to approach it?

Posted

Does the XML feed contain *all* data always? I had to deal with a slightly different issue (include a facebook news stream with search, pagination etc), and I decided to create real PW pages from all feed items. This gave me the flexibility to use the build-in functions without building an extensive Facebook API connector. 

How much items do you have to handle? 

Happy guess: you can create a WireArray (https://processwire.com/api/arrays/) from the feed data which contains already some build-in methods (unfortuantely not the pagination thingy)

 

Posted

The XML feed will contain all data related to property listings. Things like home page, about, contact, staff profiles etc will be handled in PW.

There'll be 100-150 items in the feed.

Posted

Is the data from the XML needed to be shown in real time? I'm mean, does it change A LOT every minute or so? I don't think so, as is not an auction site apparently.

So I think is a good idea to import the data as PW pages and using a cron job or manually import only the fields that changed on a daily update and import new items if not created already. 

  • Like 1
Posted
17 minutes ago, Sérgio said:

So I think is a good idea to import the data as PW pages and using a cron job or manually import only the fields that changed on a daily update and import new items if not created already. 

As long as he's not the owner of the source i don't think it's proper to create pages for the feeds that would change over-time, the only thing I can say is too fetch the XML Feeds and create a Cache for that maybe like 1 hour, to save speed. 

Posted

@Tyssen , if you decided for this approach of caching the xml, you can see how I've done this when I was getting info from Slideshare using GuzzleHttp client.

use GuzzleHttp\Client;

public function getSlideshows() {

        $client = new Client([
            // Base URI is used with relative requests
            'base_uri' => 'https://www.slideshare.net/api/2/',
            // Set timeout. 
            'timeout'  => 35.0, //Slideshare was taking long 35 seconds to respond. The xml has 100+ items.
        ]);
        
        $api_key = 'xxx';
        $username = 'xxx';
        $time = mktime(date("H"));
        $secret = 'xxx';
        $sha1 = sha1($secret].$time);

      
        $cache = wire('cache');
        $response = $cache->get("slideshare_xml");
        
        //save and cache the xml
        if(!$response) {            
            $url = $client->get('get_slideshows_by_user?username_for='.$username.'&detailed=1&api_key='.$api_key.'&ts='.$time.'&hash='.$sha1);
            $response = $url->getBody();
            $cache->save('slideshare_xml', $response); //default is 24h
        }

       

        $xml = new \SimpleXMLElement($response);        

        echo $xml;
        
        // $slide["secret_key"] = (string) $xml->Slideshow->SecretKey;
        // $slide["title"] = (string) $xml->Slideshow->Title;
        // $slide["description"] = (string) $xml->Slideshow->Description;
        // $slide["url"] = (string) $xml->Slideshow->URL;
        // $slide["thumbnail_url"] = (string) $xml->Slideshow->ThumbnailURL;
        // $slide["embed_url"] = (string) $xml->Slideshow->SlideshowEmbedUrl;
        // $slide["created"] = (string) $xml->Slideshow->Created;
        // $slide["language"] = (string) $xml->Slideshow->Language;
        // $slide["num_views"] = (int) $xml->Slideshow->NumViews;
        
        
    }

 

  • Like 1
Posted

You could always turn those xml data into custom wire objects / a big wirearray. That way you could at least use the runtime selector engine of processwire. Not as powerful as selecting from the db, but still quite useful.

  • Like 1
  • 1 month later...
Posted
On 01/03/2017 at 1:36 PM, Sérgio said:

So I think is a good idea to import the data as PW pages and using a cron job or manually import only the fields that changed on a daily update and import new items if not created already. 

I'm glad this thread is here. I might have to do exactly the same things on a job I'm looking at. I imagined the pages (about, contact etc,..) being just PW pages but the feed (I don't know the type yet) will contain the data required for the actual properties. The feed will come from a cloud CRM system where the actual properties are uploaded to.

Imagine the feed changes once a week, the PW pages have to reflect this. The property pages displayed in PW will not be edited in PW.

So how do you go about getting this feed and making PW pages out of it? This I'm confused about.

Posted
On 13/04/2017 at 9:47 AM, DaveP said:

There may be other solutions/modules but Ryan's RSS Loader Module would probably be a good starting point. It will obviously depend on the format of your source feed.

Thanks @DaveP I've now found out it is a JSON feed so I'll try and work out how to do this. I'll start a new thread instead of hijacking this one.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...