php code in templates

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
warlock
Regular
Posts: 9
Joined: Mon Feb 05, 2007 3:45 am

php code in templates

Post by warlock »

Hi all,


I'm trying to use some custom php code by including it in a template (tpl) file with smarty code like

Code: Select all

{include_php file="http://domain.com/path/to/load_nav.php"}
and can't get it to work, it says something like not a trusted resource according to smarty.

Is there something else I need to do to be able to include my own php?

Thanks in advance.
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Post by mattsches »

I guess you can only include files from your server, i.e. with a relative path. So you might try something like

Code: Select all

{include_php file="path/to/load_nav.php"}
Someone correct me if I'm wrong.
warlock
Regular
Posts: 9
Joined: Mon Feb 05, 2007 3:45 am

Post by warlock »

Thanks for your help......however using a path doesnt seem to work either.

Any more ideas?
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I believe that Smarty actually doesn't allow PHP in its templates, unless you turn the security variable off. I'm sure Garvin's mentioned it somewhere in the forums; I just haven't the time to look for it right now. You'll have to modify your config.inc.php and set a $serendipity['SMARTY'] variable.
Judebert
---
Website | Wishlist | PayPal
warlock
Regular
Posts: 9
Joined: Mon Feb 05, 2007 3:45 am

Post by warlock »

Judebert ok thanks I will look into that.......Is there any security concerns with setting that variable?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Also see http://www.s9y.org/78.html

The security concerns of this implicate that people who have FTP access to your blog can include custom PHP code in templates. And if you have the Smarty Markup plugin installed it means any author on your blog can access PHP code.

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/
warlock
Regular
Posts: 9
Joined: Mon Feb 05, 2007 3:45 am

Post by warlock »

yikes......ok thanks.....I'll read up on it.
Post Reply