4 users online. Create an account or sign in to join them.Users

Search

If I have to create dynamic XML for my data sources I need to have a PHP directory somewhere under workspace. These standalone php files will handle various http requests. Is it ok to have this model and put data source in form of http://mysite.com/workspace/php/handle-request.php?request=test or it somehow should be integrated in Symphony so I could use better formed paths like http://mysite.com/handle-request/test? Is there any tutorial or sample of user PHP files integrated with Symphony?

Thank you, Andrei

What are you exactly trying to accomplish? Perhaps there is an easier way to do it.

Do these pages generate XML? If so, you can create a Dynamic XML Data Source (create a data source and choose Dynamic XML from the Source dropdown) and give the URL as your own PHP file. You can then attach to pages as you wish.

If you want to expose this XML to users, then create your DS as above then attach to a page named /handle-request/, give the page a type of XML in Symphony, and in the page XSLT use:

<xsl:copy-of select="/data/your-data-source-name"/>

And it will output a copy of the attached XML data source.

Not so sure if I grasp what you want to create. But If you want a custom datasource; (ie running some php scripts and returning that data into an XML for symphony to process).

If so you can just create a normal datasource; find the respective datasource in workspace/data-sources/ and then modify the Grab function. There you can run PHP or whatever you want. As long as you return a Symphony XML-Element or else an XML string it should be a Valid DS. Do not forget to disable editing from the backend as this would over-write your customizations.

My site is based on "web scraping" when I got RSS feeds, or just need to fetch a page and take its content and wrap in my content. Before I used to receive a user request, fetched a feed (or page) via an HTTP request, transformed it and sent to the user the result. Now I need to go through the "dynamic XML step" (which is fine) and generate the XML based on my scraped page or feed and use XSLT to transform the dynamic source into HTML. My question was how to best organize those PHP handlers that would transform some external HTML/XML/text into XML so the Symphony pages can use them. What I was thinking was a page (say under /workspace/php/) called handler.php that could take a GET request in a form http://site.com/workspace/php/handler.php?param1=test1&param2=test2. In this case I could put exactly that link as a URL for a dynamic xml source. Inside the PHP handler I could use a HTTP_request2 class to retrieve needed content from external resources and put it in XML. I just thought that by doing so I'd be inventing a wheel since I am new to both PHP and the Symphony CMS.

If you need to output the data in HTML - the best way would be to use a Symphony page with 3 parameters (param1/param2/param3). Then create a datasource attached to that page.

Now if you want to customize the way you retrieve the data (ie it is not an XML/RSS feed) you should customize the datasource as mentioned above. At this stage you are free to use whatever php you want; as long as you return either an XML string or a symphony XMLelement (with the whole XML structure). This would then be available in your Symphony XML which you can structure using XSLT. (not sure if there is a guide somewhere how to do this but if you are well-versed in php it should not be too difficult.

Why modify the Grab function when the datasource URL php can do all the processing?

I am not sure If I understand what you mean. But you are suggesting to use an external php request; within your own website? (ie obtain the data via php and read if from symphony.) IF so, very simple - you are adding a useless http request for this datasource. If you get under high traffic; the number of requests you can process at the same time drops by half + it will be quite slower.

This would not be the case if you cache the data using the standard symphony datasource which reads from an external source.

In my opinion I would edit the datasource against using an external source; but that would vary on the 'freshness' required and other factors.

I believe we are talking about the same thing. What I am saying is that if you need to get XML data from some-external-site.com/xml?param1=test1 for your web site, then you would create a data source called "xml test1" where the URL for dynamic XML would be exactly that: "some-external-site.com/xml?param1=test1". This request would be cached and all.

Now imagine you need to rip some HTML data out of some-external-site.com/html/some-dynamic-page.html. How would you go about it? You could create a data source and modify the Grab function which would issue an HTTP request to the page, rip data and put it in XML result. Or you could create a data source with URL like your-site.com/workspace/php/handle.php?someparam=test1 so inside the handle.php you'd go and issue the HTTP request to fetch data and convert it to XML. It seems to me that the last method is more preferable since you'd utilize the caching mechanism, right? If you modify the Grab function with your own HTTP request you'd lose caching functionality.

Ah yes; no I thought it was your local site not some-external-site.com

In that case using the standard Symphony dynamic data-source facility is best-practice.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details