Is it possible to use PHP inside tpl-files?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
twe
Posts: 4
Joined: Tue Feb 12, 2008 10:12 am

Is it possible to use PHP inside tpl-files?

Post by twe »

I'm in the process of integrating s9y into an existing website that uses a lot of php for other aspects of the side. Is it possible to somehow get php instructions within the tpl file executed? They are called from a php-file afterall, aren't they?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Is it possible to use PHP inside tpl-files?

Post by garvinhicking »

Hi!

See the Smarty {php} syntax, and you must disable template security of your s9y template by editing/creating a config.inc.php file:

Code: Select all

<?php
$serendipity['smarty']->security = false;
?>
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
twe
Posts: 4
Joined: Tue Feb 12, 2008 10:12 am

Post by twe »

Thanks a lot for the fast reply! :)

Are there any negative side effects / security risks to watch out - if you only use tpl-files that have been checked (for unwanted php)?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Turning of the security simply means that you can only give FTP system access to users that you absolutely trust (because they can easily executy any PHP inside your templates now). Also it means that if you've got plugins like smartymarkup, your users can inject PHP code from within their articles.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply