Php include not working

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
MarkMushakian
Regular
Posts: 16
Joined: Sun Apr 06, 2008 6:19 am
Location: San Clemente, CA, USA
Contact:

Php include not working

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Php include not working

Post 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
# 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/
MarkMushakian
Regular
Posts: 16
Joined: Sun Apr 06, 2008 6:19 am
Location: San Clemente, CA, USA
Contact:

Post 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 :wink: .
_jwc_
Regular
Posts: 27
Joined: Tue Jun 17, 2008 9:51 pm
Contact:

Re: Php include not working

Post 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?
------------
..::JWC::..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Php include not working

Post 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
# 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/
_jwc_
Regular
Posts: 27
Joined: Tue Jun 17, 2008 9:51 pm
Contact:

Re: Php include not working

Post 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.
------------
..::JWC::..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Php include not working

Post 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
# 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/
_jwc_
Regular
Posts: 27
Joined: Tue Jun 17, 2008 9:51 pm
Contact:

Re: Php include not working

Post 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 :|
------------
..::JWC::..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Php include not working

Post 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
# 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/
_jwc_
Regular
Posts: 27
Joined: Tue Jun 17, 2008 9:51 pm
Contact:

Re: Php include not working

Post by _jwc_ »

You are great Garvin,

now is working.
debugging showed my mistekes :/

thanks a mil
------------
..::JWC::..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Php include not working

Post by garvinhicking »

Hi!

What was it, was the path still wrong?

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/
_jwc_
Regular
Posts: 27
Joined: Tue Jun 17, 2008 9:51 pm
Contact:

Re: Php include not working

Post 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
------------
..::JWC::..
Post Reply