Search

Hi all,

I've been asked to help with a website for a UK charity that has run out of money to complete the job. Whilst most of the site is complete some important sections have not yet been created. I've been unable to find a Symphony developer who'll work for peanuts so am now trying to complete the work with the help of a friend.

The other chap is pretty good with PHP so we're trying to do as much as possible in Symphony and do the more complicated parts in PHP.

First steps were to try and call PHP from within XSL. We've tried Andrew Shooner's extension, starting with his 'Hello World' example. The extension was uploaded and enable, associated page and XSL created but we only get errors...

eg ;

XSLTProcessor::importStylesheet():
    compilation error: file efm://functions line 7 element param
    element param only allowed within a template, variable or param
    compilation error: file efm://functions line 8 element copy-of
    element copy-of only allowed within a template, variable or param
    compilation error: file efm://functions line 10 element param
    element param only allowed within a template, variable or param
    compilation error: file efm://functions line 11 element copy-of
    element copy-of only allowed within a template, variable or param
    compilation error: file efm://functions line 7 element function
    Failed to register function {http://example.com}hello
    compilation error: file efm://functions line 10 element function
    Failed to register function {http://example.com}hellonode
XSLTProcessor::transformToXml():
    No stylesheet associated to this object

Next came the example from Carson Sasser http://tech.carsonsasser.com/article/how-to-register-and-use-custom-php-functions-inside-xsl

Unfortunately, his example also fails to run on our system with the following error (when I only include the unix time function)

XSLTProcessor::transformToXml():
    Not allowed to call handler 'time()'

We are now running out of time so unless we can find a way to persuade Symphony to run custom PHP we'll have to re-do the site using another platform or even hand code it.

I'd imagine that the examples should work without any other changes to Symphony or have I got that wrong? Could our platform perhaps be causing our problems?

Sorry for the essay!

Thanks in advance,

Carl

I've been asked to help with a website for a UK charity that has run out of money... I've been unable to find a Symphony developer who'll work for peanuts...

Doesn't solve your problem, but here's an interesting article about non-profits that might explain why people around here won't work for free (well, not for clients, at least).

Why non-profit pricing?

Hey Carl,

It'd be useful to know what sort of functionality you're looking to achieve with PHP.

User interaction from the Front-end is usually done using Events in Symphony. Custom PHP code can be added to these events and kept separate from your XSLT.

Theres some really smart guys in this community though that would be able to point you in the right direction, but as I say it'd help to know what you're trying to achieve as your solution (php in xslt) may not be ideal.

@jensscherbl, it was actually more about the timescale than the money involved. A couple of developers said that they would have liked to help but did not have the time due to other work. Poor wording on my part perhaps!

@heskethm, As we have no knowledge of Symphony we need to do everything outside of basic text content via PHP. For example, we need an online application form for the volunteers. We can spend some time working out how to do it in Symphony or do it in PHP. Unfortunately, as time is one of the things that we do not have we'll need to use PHP. There are also dynamic galleries, maps and interactive content, I'm sure Symphony can handle these but we're out of time!

I've tried adding PHP to Events as per the example in my first post but it didn't work. I think our first step must be to get basic PHP and then I can look into which bits I can do in Symphony whilst the PHP guy works on the more complicated stuff.

@carlsalter do you have the documentation of the project? Maybe looking exactly what need to be done we can give you a nice feedback on the steps you'll need to go.

I'm pretty confident that most things are possible to do with Symphony without need PHP hacking. Anyway, you also can check if this extension is helpful exsl function manager

Hi Carl,

If you let us know what it is you want the PHP to do, I'm sure that as a community we can get a solution for you using Symphony's native Events and XSLT.

This article may help, it looks like the error you are receiving is because the time function is restricted or perhaps you are running PHP5.2?

I realise that with a deadline looming you want to try and implement as much as possible with PHP, but understand that in a way you are working against the CMS so might run into some issues doing this.

For your use case of creating a Form, Symphony offers a really quick way to get this up and running!

  1. Create a Section with the Fields that you want to store user's data in. eg. Name, Email, Message
  2. Create an Event, call it what you like, link it to the above Section and save it.
  3. Create a Page where you want the Event to live, eg. /contact/.
  4. The Event generates the markup needed to create the form on the frontend, so copy and paste it into your page template.
  5. Dance!

Hi all, thanks so much for your feedback and encouragement!

I decided to swap the laptop for red wine and a nights sleep then revisited the code this morning, I have now got PHP working within the site using Symphony events, thanks Carson Sasser!

Everyone involved would like to stick with Symphony but even the volunteer form is not straight forward.... The form must be dynamic and display different entry fields, menu choices, downloadable volunteer forms and choose who to email the results to based on the information supplied by the user. It's a big lump of code in PHP so getting this level of complication dealt with in Symphony is not likely to be easy.

We have the same issue with the photo gallery, the upload requirements (e.g. smartphone photo taken from a very rural location on the other side of the world by someone who has probably never seen a smartphone before) suggests that it would be considerably faster to embed something like a Flickr gallery.

Only 6 days left before it's supposed to be live so I'd better get back to work, I suspect I may be returning soon for some words of wisdom.

Thanks again!

I said I'd be back... Here's one for a smart Symphony guy...

I have a custom event with a couple of test PHP functions and the PHP function that I need to use. The event is attached to a page and called with <xsl:value-of select="php:function('*name*')"/>

When I call a test function form within the page template it appears exactly where I expect. When I call the longer PHP code that I actually need (Reads the contents of an image folder and displays those images) the page is created with the PHP function at the top of the source (I mean literally! Above <head>!!)

The test functions (EG, Unix Time and a simple echo) stay exactly where they are supposed to be. It's just the my custom code...

Am I missing something obvious?

I reformatted your comment to allow the xsl and head tag. Code like that has to wrapped in backticks to allow it to be shown :)

Ooops, thanks, did I mention that I was new to Symphony? ;)

:o)

Alas, I have zero experience with php in xslt.

You would be better using a datasource to output things like image galleries into xslt rather than an event. Events are meant to output a response to an input (like POST) whereas datasources are for data output (like GET).

That being said, I understand your time constraints. I hope someone else responds with experience in what you're doing.

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