Search

I've started playing with the possibility to have DS's getting data from other sites, like Flickr and Jaiku. But how do you handle the situation where the site you want to fetch a feed from is down for the moment? I'm gettig a "Data missing"-error, or something similar.

Edit: Too quick. I should have checked the xml before asking. Of course, there was an error node.

Thoresson, there is a solution, but it's a little bit fiddly.

I have found using a PHP script as a proxy middle-man works very well. Your Dynamic DS points to this PHP script on your server. The PHP fetches the feed itself and caches it as an XML file on the server. It has logic to see whether the cache has expires and attempts to refetch the remote feed rather than serving Symphony the local cached XML. If the feed can be retrieved, then it is served and resaved locally. If it fails (i.e. Flickr is throwing a tantrum) then the proxy returns the old XML.

This way you always have something to return.

Nice solution. But what do you mean having a DS pointing do a PHP script? Got a real world example?

When you create a Dynamic XML Data Source, you can set the URL to anything. It doesn't have to be to an XML or RSS feed, it could be to a PHP script that outputs XML.

If you've not used a Dynamic XML Data Source, create a new DS and select "Dynamic XML" from the Source drop down. In the example I've set the URL to point to a file called "fetch_xml.php" that sits in the root of my site. You can use the usual $params in this field to dynamically create the URL, and pass DS output parameters to it if you need to.

Dynamic XML DS
http://flickr.com/photos/nickdunn/2889742266/

In your PHP script you then need to do the consuming and caching of the XML feed, set the content type as "text/xml" and return whatever you want to use in Symphony.

You don't happen to have an example of a working PHP setup? I haven't done any actual PHP development in a couple of years...

Not to hand. But the functionality would be similar to the image.php that ships with Symphony. It checks the file system for the cached image and grabs a new one if it has expired.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details