shinji
03-16-2004, 06:23 AM
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 (http://www.phpdig.net/showthread.php?s=&threadid=469) 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 (http://www.napathon.net/test/makeheadfoot.txt) is the way I've done it.
Here (http://www.napathon.net/test/Navigation.txt) is a very oversimplified example of my header/footer PHP classes.
Make a file called header.php with the following:<?php
echo $Navigation->getHeader();
?>
Make a file called footer.php with the following:<?php
echo $Navigation->getFooter();
?>
In search_function.php, add the following code right after the function statement: 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:$t_mstrings = compact('powered_by_link','title_message','phpdig_version','result_message' ,'nav_bar','ignore_message','ignore_commess','pages_bar','previous_link','n ext_link','templates_links');
Replace it with the following code:$t_mstrings = compact('my_header_file','my_footer_file','powered_by_link','title_message' ,'phpdig_version','result_message','nav_bar','ignore_message','ignore_comme ss','pages_bar','previous_link','next_link','templates_links'); Be sure you remove any word wrapping in the above code.
Here (http://www.napathon.net/test/search_function.txt) 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:<phpdig:my_header_file/>
Replace the following code at the bottom of your template:</body>
</html> with the following code:<phpdig:my_footer_file/>
Here (http://www.napathon.net/test/phpdig.html) 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. :)
vBulletin® v3.7.3, Copyright ©2000-2025, Jelsoft Enterprises Ltd.