Forums / Setup & design / Embedding PHP within templates
Andy Woods
Monday 04 April 2011 11:07:23 am
Hi,
How easy is it to embed PHP within template files?
Can you give me any step-by-step examples of how to do it please?
Thanks,
Andy
Nicolas Pastorino
Monday 04 April 2011 11:43:51 am
Hi Andy,
It is not possible directly. The way is to extend the template engine/language through :
Cheers,
-- Nicolas Pastorino Director Community - eZ Member of the Community Project Board eZ Publish Community on twitter: http://twitter.com/ezcommunity t : http://twitter.com/jeanvoye G+ : http://plus.tl/jeanvoye
Marko Žmak
Monday 04 April 2011 2:01:57 pm
Also, the wrap operator extension could be usefull:
It's a wrapper that allows you to use any PHP function inside the eZP templates.
Of course, you must use this wisely and with caution.
-- Nothing is impossible. Not if you can imagine it! Hubert Farnsworth
Tuesday 05 April 2011 12:06:23 am
Hi Marko,
Thank you for your help - can you tell me what I need to be careful of when using PHP please?
Tuesday 05 April 2011 12:33:05 am
Well you'll have to be caerfull about pretty much the same thing when coding in pure PHP. Performance and security issues mostly. To make a list of it would be out of the scope for this forum.
The main "problem" is that when you use the eZP template language, the eZP itself takes care of many performance and security issues, and if you use much PHP within templates you lose this layer of protection.