Search

I'm using the document() function in a page to get data from last.fm. This works nicely most of the time, but every now and then it doesn't, and when it breaks, the whole page breaks, with the warning, failed to load external entity "http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&..... and/or failed to open stream: HTTP request failed!

Is there a way I can check whether or not the connection will be made successfully to prevent the page from breaking?

I tried wrapping the document() function in a boolean() function to test for the file's existence (as mentioned here) but I haven't managed to get that to work, either.

You could also get the data using a Remote Datasource. It supports caching and should also be able to tell you what exactly is wrong.

In this instance, I want to display the album image of my most-listened-to album of the week, but the last.fm method for weekly album charts doesn't include images in the data it delivers – it only includes the artist name and album name.

So, I get the artist name and album name, then feed those into another API method, which gets album information (including images).

I thought I had to do this on the fly within the XSLT, but could I use a Remote DS (or two)? I've not quite got my head around how this could work.

But you can do all that with Remote Datasources.

OK.

I've not quite got my head around how this could work.

I'll try to get my head around how this could work.

I've scratched my head for a while and haven't figured out how to do this with remote datasources.

I use a remote DS to get the first album in my weekly top albums list, then I want to use the 'artist' and 'album' elements returned as dynamic portions of another remote DS URL, but how do I do this without those elements being in the param pool (or, how do I get them in to the param pool)?

I think you can use Parametrisator to do this.

Parametrisator allows you to use XSLT and XPath to select data from XML (generated by any type of data-source), copy it into parameters and add to the parameter pool used by other data-sources. It works with any type of data-source distributed with Symphony, as long as it is editable and returns XML data.

Thanks, David; so I'm not overlooking something howlingly simple with remote data sources, then?

No, Remote Datasources do not output parameters unlike their section cousins. It has been requested however, so it may feature at some point in time.

OK, so will Parametrisator circumvent my initial problem (will it prevent the page from breaking if there's a problem with last.fm for whatever reason)?

Or, is there a way to check if I'm going to get good data from last.fm in the page's XSLT?

If you would want to output some params from the remote datasource - its possible. There is a hook post-datasource-generate. Check if its the DS you would like to get the data on - parse the data and output the params. Did this before. If you need some sample code I'll try find it and put it up somewhere.

@gunglien, this interests me. Just in the throws of proposing a portfolio type site where the client wants to provide the feed of XML data from one location and would like a satellite site that ingests this info into a Symphony Build we're putting together.. if filtering via params was possible like you say, I'd love to take a look at a little sample code for reference if that was cool?

If you're all using 2.3 then may I suggest the Remote Datasource as a starting point for a customisation? It is a Provider now so can be customised to provide API access etc...

Stable for production you think? symphonyextensions.com still has it flagged as experimental.

That may be an oversight in the meta file, I will poke Brendan to sort it out.

Tidy darts :)

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