Page 1 of 1
Php include not working
Posted: Tue Dec 09, 2008 8:19 am
by MarkMushakian
Hi folks,
I've recently decided to move my blog from it's folder into the main site root and use it as my main index page. All has gone well, but as I am now redesigning the default template to match my previous index page, I am not able to use this code to bring in my own personal sidebar for my site's navigation/links...
Code: Select all
<?php include("/siteRootHere/leftcolumn.php"); ?>
Before I made the transfer, I was trying things out on a test installation, and I was using the Default-PHP template - where the php include worked. However, after getting errors on things like the comments, I found a forum post by Garvin stating that the default template should be used instead - however, I'm not sure as to why the php include no longer works. Does Serendipity's default template only output html? I'm under the assumption now that this might be my problem - so how then can I use php?
Thanks for the time. I'm THIS close to finally having my site finally set up how I want, and I'm really glad I've been able to figure it out while still keeping Serendipity as my blog.
Re: Php include not working
Posted: Tue Dec 09, 2008 11:48 am
by garvinhicking
Hi!
Yeah, the default-php template is really meant for developers as a starting point; it is not ready to be used in production without adaptions.
PHP Code cannot be used in usual smarty code. To use PHP there, please check out this:
http://www.s9y.org/78.html#A4
HTH,
Garvin
Posted: Tue Dec 09, 2008 6:27 pm
by MarkMushakian
Thank you very much, sir! I thought I'd exhausted every resource on the site looking for an answer - I guess I missed one

.
Re: Php include not working
Posted: Wed Feb 18, 2009 11:33 am
by _jwc_
Hi Garvin
I modified the config.inc.php how explained adding this first row
$serendipity['smarty']->security = false;
and adding
{include_php file="include.php"}
in my index.tpl but without any result.
the include.php file is at the same level of my index.tpl and doesn't have fancy code that can make troubles.
Does anyone have any idea why doesn't work?
Re: Php include not working
Posted: Wed Feb 18, 2009 11:57 am
by garvinhicking
Hi!
You might need to provide a full path to your include.php script; else the local current directory might be different, so that smarty looks for "include.php" in the root directory of serendipity, not in the relative directory of the template.
Regards,
Garvin
Re: Php include not working
Posted: Wed Feb 18, 2009 1:22 pm
by _jwc_
Thanks Garvin,
I tried the following
{include_php file="
http://mydomain.com/include/file.php"}
{include_php file="/include/file.php"}
{include_php file="include/file.php"}
but it still doesn't work.
Re: Php include not working
Posted: Wed Feb 18, 2009 2:20 pm
by garvinhicking
Hi!
Hehe. All of them are wrong. You need to use file="/path/to/your/serendipity/and/full/include/file.php".
If you have s9y installed in /var/www/htdocs you would need to use file=/var/www/htdocs/templates/yourtemplate/file.php. You can find your whole path by looking at the s9y configuration, it's there in "full path to serendipity".
Regards,
Garvin
Re: Php include not working
Posted: Thu Feb 19, 2009 12:28 am
by _jwc_
Apologize, it seem more difficult than mine expectation..
I used the full path.
I have a linux enviroment /home/myFolder/public_html/myFolder2/testxxx/
the url is
http://testxxx.mydomain.something
I wrote
{include_php file="/home/myFolder/public_html/myFolder2/testxxx/templates/myTemplate/include.php"}
is there any way to debugg it?
It still doesn't work

Re: Php include not working
Posted: Thu Feb 19, 2009 10:30 am
by garvinhicking
Hi!
What about when you use this smarty code:
Code: Select all
{php}
$f = '/home/myFolder/public_html/myFolder2/testxxx/templates/myTemplate/include.php';
if (file_exists($f)) { echo 'File exists'; } else { echo 'File does not exist'; }
include $f
{/php}
Regards,
Garvin
Re: Php include not working
Posted: Thu Feb 19, 2009 10:44 am
by _jwc_
You are great Garvin,
now is working.
debugging showed my mistekes :/
thanks a mil
Re: Php include not working
Posted: Thu Feb 19, 2009 10:52 am
by garvinhicking
Hi!
What was it, was the path still wrong?
Regards,
Garvin
Re: Php include not working
Posted: Thu Feb 19, 2009 12:01 pm
by _jwc_
The path was wrong. I made a syntax error
During a tentative I have certainly wrong the path and then I gave for assumption it was right.
Debbugging show the label displaied with echo and I discovered the mistake.
Apologize for that