Author Topic: How can I include another PHP file in the templates?  (Read 120941 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
How can I include another PHP file in the templates?
« on: February 23, 2003, 10:02:35 PM »
Open the 4images html template where you would like to include your PHP file and include it like this:
Code: [Select]
<?php 
include($_SERVER['DOCUMENT_ROOT']."/relative/path/to/my/include.php"); 
?>
Next, open includes/constants.php and change
Code: [Select]
// Allow execution of PHP code in templates
define('EXEC_PHP_CODE', 0);
to this
Code: [Select]
// Allow execution of PHP code in templates
define('EXEC_PHP_CODE', 1);

PLEASE be sure to read this FAQ forum topic: http://www.4homepages.de/forum/index.php?topic=3378
for information regarding some limitations and possible solutions for working with certain types of PHP scripts.

[UPDATE]
If you are using relative path ./ inbetween the templates, then be advised, that php will look for files in includes/ directory and not 4images root!
i.e. if used
Code: [Select]
<?php
include("./somephpfile.php");
?>
the somephpfile.php must be placed in includes/ folder.
« Last Edit: January 29, 2006, 07:56:18 AM by V@no »

Offline khan

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #1 on: July 31, 2005, 10:51:49 PM »
HI
I Did every thing described above but php including does not works in my templates.
at the place where i included the php file its display blank area and does not Showing the data of the included Php file.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How can I include another PHP file in the templates?
« Reply #2 on: July 31, 2005, 10:58:50 PM »
and what does it show u when u try open that file directly in the browser as a web page?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline khan

  • Newbie
  • *
  • Posts: 35
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #3 on: August 03, 2005, 08:57:39 PM »
Hi
When i open it in browser it display every thing inside the files. but when i include it in 4images it displays blank white area.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How can I include another PHP file in the templates?
« Reply #4 on: August 04, 2005, 01:03:01 AM »
sounds like a conflict between 4images and your script.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline tatty

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #5 on: February 23, 2006, 02:59:13 AM »
Hello.
For me it's not working too :(
I've done what told in the post, but when I click "save changes" it shows me a blank space. I go to the gallery page and no changes were done! I mean, I add the php include but no changes happen.

Any suggestion? Thanks!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How can I include another PHP file in the templates?
« Reply #6 on: February 23, 2006, 03:23:04 AM »
Did you apply all the bug fixes? I guess you didnt.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline killerwhale65

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #7 on: March 10, 2006, 12:41:10 PM »
what if i want to include a php file on the frontpage (index.php)? How can i do that?

thanks!

Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #8 on: March 10, 2006, 01:51:27 PM »
...How can i do that? ...


Exactly the same as here described !
Your first three "must do" before you ask a question ! ( by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline killerwhale65

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #9 on: March 10, 2006, 01:54:23 PM »
and what is the html template i should use? I dont find an index.html ...

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How can I include another PHP file in the templates?
« Reply #10 on: March 10, 2006, 01:56:51 PM »
home.html
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #11 on: March 10, 2006, 01:59:20 PM »
as you can see on top of index.php
Code: [Select]
$main_template = 'home';

the template for index.php ist home.html ... :!:
Your first three "must do" before you ask a question ! ( by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline colorssky

  • Full Member
  • ***
  • Posts: 128
    • View Profile
    • http://www.nnjj.net
Re: How can I include another PHP file in the templates?
« Reply #12 on: October 09, 2006, 11:03:23 PM »
I tried to add the follwing, because I am using poll script

______________
<?php
include($_SERVER['DOCUMENT_ROOT']."/home/takfeed/public_html/poll/booth.php'");
display_booth(1); ?>
_______________

but I got this error

Warning: Unknown(/home/takfeed/public_html/home/takfeed/public_html/poll/booth.php'): failed to open stream: No such file or directory in /home/takfeed/public_html/shop/includes/template.php(101) : eval()'d code on line 84

Warning: Unknown(/home/takfeed/public_html/home/takfeed/public_html/poll/booth.php'): failed to open stream: No such file or directory in /home/takfeed/public_html/shop/includes/template.php(101) : eval()'d code on line 84

Warning: (null)() [function.include]: Failed opening '/home/takfeed/public_html/home/takfeed/public_html/poll/booth.php'' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/takfeed/public_html/shop/includes/template.php(101) : eval()'d code on line 84

Fatal error: Call to undefined function: display_booth() in /home/takfeed/public_html/shop/includes/template.php(101) : eval()'d code on line 85


Offline iraklis

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #13 on: January 05, 2007, 03:10:56 PM »
've problems too.

Parse error: parse error, unexpected '/' in /dev/httpdocs/includes/template.php(133) : eval()'d code on line 372

Anybody an idea?

Offline KurtW

  • 4images Guru
  • *******
  • Posts: 2.778
    • View Profile
    • Malediven-Bilder ~~Dreams~~
Re: How can I include another PHP file in the templates?
« Reply #14 on: January 06, 2007, 02:52:22 PM »
Hi colorssky,

Code: [Select]
<?php 
include($_SERVER['DOCUMENT_ROOT']."/poll/booth.php"); 
?>

To iraklis

To mutch / in your code.



cu
Kurt

 

Post your comments here