![]() |
PHP includes in templates
I have read through the forums, but still need help using PHP includes in the templates. Can someone please give detailed instructions on how to do this with some examples.
Maybe, somehow show how to include a header include and a footer include in the template file. I would love to use this excellent app... just need a little help to do it. |
Hi. Say you want to include header.html and footer.html in a template.
First add the following function to the top of the search_function.php file: PHP Code:
PHP Code:
PHP Code:
Code:
<phpdig:my_page_header/> |
Wow, thanks for the in-depth reply. Exactly the response I was looking for. I think this will help a lot of people out including myself.
|
By the way, it worked like a charm. Thanks again.
|
RE: PHP includes in templates
This is brilliant! Any way to modify this so that it can include AND parse any PHP in the include?
|
Hi. Using the same method as above, you could include header.php, sidebar.php, and footer.php in a template, or you could also make your own custom PHP search page as follows.
In the search.php file do the following: PHP Code:
PHP Code:
|
Charter:
I followed your code above, modifying search_function.php and the template. I included a header and footer file. My scripts search_function.php Code:
I added to the top: Code:
$my_page_header = get_my_includes("./includes/header_aux.inc.php"); Code:
<phpdig:my_page_header/> Cheers, JC |
Quote:
<edit> BTW, I forgot to welcome you to the forum. Glad you could join us! :D </edit> |
Hi. To parse PHP files, remove the get_my_includes function, as that reads but does not parse PHP files, and then replace:
PHP Code:
PHP Code:
|
Ok, Pat and Charter, I have tried both of your code examples. Thanks for the advice but I am still not having success... I decided to go with Charter's example for simplicity. I removed the get_my_includes function and changed the other code in search_function.php to
Code:
$my_header_file = include("./includes/header_search.inc.php"); Code:
<phpdig:my_header_file/> Any other ideas on how I can get it to print a header then the phpdig content then the footer, in that order? Cheers, JC |
Hi. Try taking a look at the HTML source from your page and then in the template just move <phpdig:my_header_file/> and <phpdig:my_footer_file/> so that the order is correct.
|
Charter, thanks. There appeared to be no way to reorder the way they are listed to provide the desired result, given the order is
Code:
<phpdig:my_header_file/> I'm on a time limit so I gave up and hardwired the HTML into the template and got the result I 'wanted'. Thanks for your help. |
I was having same problem as jclabaugh - order of template header and footer.
Found that this ordering is not adjusted in the HTML template file, it must be adjusted via the order of elements appearing in /libs/search_function.php Code should read something like this to place footer below PHPDig search results: PHP Code:
|
Welcome to the forum, subscript. :D
Your method of including a custom header/footer is certainly a pretty simple way of doing it. Thanks for sharing. It's nice to have someone post one more way of doing it. :) |
Also, from php.net:
return.php PHP Code:
PHP Code:
PHP Code:
|
All times are GMT -8. The time now is 02:03 AM. |
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.