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

0 Members and 1 Guest are viewing this topic.

Offline osnapicture

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #15 on: February 21, 2007, 11:10:01 PM »
is there anybody who could help me? i tried everything but i can't include a php file. maybe i used the wrong directory.
i would like to include the index page of a guestbook which you can find in www.mydomain.com/templates/default/guestbook/index.php
what would be the right code to include this into an html-template site?
« Last Edit: February 21, 2007, 11:35:38 PM by osnapicture »

Offline shaiba81

  • Pre-Newbie
  • Posts: 4
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #16 on: March 29, 2007, 05:46:41 AM »
Exactly the same as here described !

Offline CeJay

  • Sr. Member
  • ****
  • Posts: 425
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #17 on: March 29, 2007, 06:59:41 AM »
you can not include a php file/page into a html page, if your html page is a template for 4images then follow directions again.
Otherwise if you have a home page that is a html page you can not call a php page into it.

Offline Flo2005

  • Full Member
  • ***
  • Posts: 237
  • Copy & Paste Profi :)
    • View Profile
    • snuup.de! - Bilder - Sounds - Videos - fun4FREE!
Re: How can I include another PHP file in the templates?
« Reply #18 on: April 01, 2007, 02:07:07 PM »
WeŽll I think if you want to integrate a complete new php-file you have to do:

edit: all files

categories.php
details.php
index.php
lightbox.php
member.php
postcards.php
register.php
search.php
top.php

search for this:
Code: [Select]
require(ROOT_PATH.'includes/sessions.php');
and add this after:
Code: [Select]
include(ROOT_PATH.'my_new_phpfile.php');
Upload your new phpfile in the root of your 4images installation.

There was a topic where chris has written how you can call this file in your template html-files

Project offline

Offline adrian.gab

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #19 on: July 10, 2007, 02:38:40 PM »
Is there a special trick to getting the 4images tags (e.g. {template_url} {if random_image} {site_name}) to work within an include file called from a template file e.g. home.html, details.html?

See my post here for more info:

http://www.4homepages.de/forum/index.php?topic=18003.msg95825

Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #20 on: July 10, 2007, 03:06:33 PM »
... there is no trick ...
... the tags works only in the templates by their php-files in which they was generated ...
... e.g. ...
... tags in home.html are generated in index.php ...
... tags in details.html are generated in details.php ...
... a.s.o. ...
... but some tags are generated in functions.php ...
... to use the tags in templates you must call the pertinent php-file in the browser, not the template-file ...
... so ...
... if you want to use tags, you must edit a php-file which generated these tags and call the template ...
... have a look in details.php ... and ... details.html to see how it works in 4images ...
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 adrian.gab

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #21 on: July 10, 2007, 04:20:43 PM »
ok, i think i sort of understand. the tags will only work when a template file is read from a php file e.g.

$site_template->print_template($site_template->parse_template($main_template));

am i understanding this right? that is a shame, i wish it would just parse / read the tags from include files called from templates.

what if i want to call a template within a template?

this is what i am trying to achieve. the templates are labourious to update. if i make a change i generally have to update all of them. since nearly all of the templates are indentical except for the contents of one table cell, i would like the non changing content to be one file and the changing content as another file. this way if i update a header or something like that, then i don't have to edit all of the templates.




Offline webmaster73

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #22 on: July 27, 2007, 11:29:42 PM »
I have long long been looking .......  I wish I searched here before trying to figure out this alone.


Offline webmaster73

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #23 on: September 28, 2007, 02:20:54 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"); 
?>


works like a breeze. so easy. thank you very much.

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: How can I include another PHP file in the templates?
« Reply #24 on: September 28, 2007, 08:34:04 PM »
If use in 4images -

replace:

Quote
include($_SERVER['DOCUMENT_ROOT']."/relative/path/to/my/include.php");

for:

Code: [Select]
include($HTTP_SERVER_VARS['DOCUMENT_ROOT']."/relative/path/to/my/include.php");
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?