PhpDig.net

PhpDig.net (http://www.phpdig.net/forum/index.php)
-   How-to Forum (http://www.phpdig.net/forum/forumdisplay.php?f=33)
-   -   footer/header with php (http://www.phpdig.net/forum/showthread.php?t=680)

shinji 03-16-2004 06:23 AM

footer/header with php
 
Hi,

i've got the problem that i cant use php in the templates...

so i want to ask.. how can i add php code as a header and/or footer? :p

vinyl-junkie 03-16-2004 07:25 PM

This thread has just what you need. After reading that, if you have any questions, feel free to ask, because I've done exactly what you're wanting to do. :)

shinji 03-17-2004 03:29 AM

seems that some codes have changed since 1.8

i couldnt find some of the to-replace codes...

vinyl-junkie 03-18-2004 07:59 PM

Perhaps I had some customized code that I forgot about. I downloaded a fresh copy of 1.8.0, set it up and configured it in a different directory on my site to test all this out, so here is a step-by-step explanation of how to do it.

Make a file called makeheadfoot.php which calls the PHP class that creates your header and footer. Here is the way I've done it.

Here is a very oversimplified example of my header/footer PHP classes.

Make a file called header.php with the following:
PHP Code:

<?php 
echo $Navigation->getHeader(); 
?>

Make a file called footer.php with the following:
PHP Code:

<?php 
echo $Navigation->getFooter(); 
?>

In search_function.php, add the following code right after the function statement:
PHP Code:

require("/path/to/makeheadfoot.php");

ob_start(); 
require(
"/path/to/header.php"); 
$my_header_file ob_get_contents(); 
ob_end_clean(); 

ob_start(); 
require(
"/path/to/footer.php"); 
$my_footer_file ob_get_contents(); 
ob_end_clean(); 

Also, find the following code in search_function.php:
PHP Code:

$t_mstrings compact('powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links'); 

Replace it with the following code:
PHP Code:

$t_mstrings =   compact('my_header_file','my_footer_file','powered_by_link','title_message','phpdig_version','result_message','nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','next_link','templates_links'); 

Be sure you remove any word wrapping in the above code.

Here is a text version of my search_function.php file so you can take a look at exactly how I did it.

In your template file, replace everything at the top, through the <body> tag with the following:
PHP Code:

<phpdig:my_header_file/> 

Replace the following code at the bottom of your template:
PHP Code:

</body>
</
html

with the following code:
PHP Code:

<phpdig:my_footer_file/> 

Here is my template with the old code commented out and the new code inserted.

Let me know if I've missed anything, and if you still have problems. I'll be glad to help. :)


All times are GMT -8. The time now is 05:10 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.