PhpDig.net

Go Back   PhpDig.net > PhpDig Forums > How-to Forum

Reply
 
Thread Tools
Old 03-16-2004, 06:23 AM   #1
shinji
Green Mole
 
Join Date: Jan 2004
Location: Hamm/NRW/Germany
Posts: 26
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
shinji is offline   Reply With Quote
Old 03-16-2004, 07:25 PM   #2
vinyl-junkie
Purple Mole
 
Join Date: Jan 2004
Posts: 694
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.
vinyl-junkie is offline   Reply With Quote
Old 03-17-2004, 03:29 AM   #3
shinji
Green Mole
 
Join Date: Jan 2004
Location: Hamm/NRW/Germany
Posts: 26
seems that some codes have changed since 1.8

i couldnt find some of the to-replace codes...
shinji is offline   Reply With Quote
Old 03-18-2004, 07:59 PM   #4
vinyl-junkie
Purple Mole
 
Join Date: Jan 2004
Posts: 694
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.

Last edited by vinyl-junkie; 03-18-2004 at 08:02 PM.
vinyl-junkie is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
skipping header and footer joelstein How-to Forum 1 10-19-2005 07:55 AM
"1 1" between page header and search result jensb Troubleshooting 2 01-13-2005 01:37 PM
Mod to follow header redirects Charter Mod Submissions 0 02-25-2004 10:33 AM


All times are GMT -8. The time now is 03:22 AM.


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