Search

Hi clever people...

Hoping to pick your brains.

I have a remote datasource - instagram. That works just fine.

I want to integrate it with some news (from a standard datasource). But I'd like to be able to merge the two somehow and order them by date.

Instagram sends back a unix timestamp and symphony does not.

Any bright ideas? I was going to try and customize my remote datasource, but I can't actually figure out how to do that. Is that the best place to start?

Any ideas?

Thanks! /tasha

I would think of the xml import extension and a cron job to update. With xml import you can use a php function to turn the unix timestamp in a date format you prefer.

Or union datasource and with a reference field you transform the date from the symhony datasource to unix time or vice versa.

Unix timestamp is nothing more than the count of milliseconds from the date 01-01-1970 00:00:00 till today.

I hope this give some bright ideas. Happy coding!

Hey Tasha,

It's certainly possible to merge two data sources, if you want to customise / get a bit dirty with your datasource it's certainly possible.

You can modify the datasource by re-defining the execute function. You can start with the data which is presented through the parent function, within the $result variable, parse the XML and do whatever you have to do. I've done it a few times when I needed to re-structure the XML or else when I needed to add arbitrary data from within Symphony to the original remote datasource nodes.

If you're not quite sure with what I mentioned, I can try explain it in finer detail.

Hey guys

Thanks for the input!

I've never modified a datasource before...

So would the theory be that if I re-structured the instagram XML, I'd then be able to use union datasource to combine the two?

Thanks! /t

Sorry, one more question - what's the best way to be able to echo out things to see what's going on when trying to write overrides?

hmm, personally I put var_dumps and kill the page from rendering to check the data. But there are other tools to output results. I'd also suggest you familarize yourself with the XMLElement API in symphony as ideally you create XML in that format.

In theory it's possible to restructure and combine but I've never used it for union datasource.

If I try customising my own grab function inside my remote datasource and dump $result just before the return statement,

I get:

object(XMLElement)#53 (13) { ["name":"XMLElement":private]=> string(10) "instagram2" ["value":"XMLElement":private]=> string(180709) "

etc...

So the XML is all in string - so I can't traverse it using XMLElement. Is there a different function that I should be overriding?

As of I'm not the real backend coder. I would pull the json from instagram with remote datasource. Make a new page with type xml and include the instagram datasource.

In the page template put:

<xsl:template match="/">
    <xsl:copy-of select="data"/>
</xsl:template>

And there is your own xml to handle with in Symphony.

Ah when it's a string I tend to open up with an XML parser, if you want to keep things simple you could use something like SimpleXML, open up the string parse it and do whatever you want. But importantly only return an XML string or an XMLElement symphony object. Remote datasource if not mistaken always gives you strings to work with, as it only checks the validity of the XML.

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