jeskel
16th January 2005, 06:26 AM
Hello :)
I would like to include a file in one of my templates. There is the code available in the adminCP in the phpinclude_start textarea.
Is that what I should use? Should I just copy it in the template (uncommented and with the proper filename, of course)?
:)
Pie
16th January 2005, 01:41 PM
you can always
include("file.ext"); in your phpinclude_start HOWEVER it depends what the contents are... as to what will happen.
jeskel
17th January 2005, 12:38 AM
including it in the phpinclude_start is nice, for sure... but how can you control where it's going to be displayed on your forum?
It's a very simple .html file (it could be .txt file). The thing is: this file is frequantly updated by another app. That's why I want to include it on my board, to reflect the new entries of the other app.
In the adminCP, you have this example:
// Example of how to include a seperate file:
// ob_start();
// require("yourheader.html");
// $header = ob_get_contents();
// ob_end_clean();
my question is: should I cut and paste this code snippet where I'd like the included file to be displayed (uncommented and with the proper filename)?
thanks for your reply and your help :)
Pie
17th January 2005, 12:44 AM
No problem.
My PHP is rusty but underneath all the // coments on phpinclude_start try this:
$data = include(file.ext);
and then insert $data where you want it in a different template.
PS- if the file is in a different folder change the file to: ./folder/file.ext [.. = directory up]
Chroder
17th January 2005, 02:27 AM
You can't do that. include() doesn't return the contents of a file, it will return false on error only. Unless you use 'return' in your included file, then in that case it returns what you want it to return.
Anyway, the commented PHP is a fully working example, just replace the filename and/or variable name. Or you can do more then one:
ob_start();
require("header.html");
$myheader = ob_get_clean();
require("footer.html");
$myfooter = ob_get_clean();
ob_end_clean();
Then stick $myheader and $myfooter wherever you want within your templates.
my question is: should I cut and paste this code snippet where I'd like the included file to be displayed (uncommented and with the proper filename)?
Nope, keep it in phpinclude_start. The contents will be assigned to the variable, which you can then use anyway in your templates. For example:
Blah blah blah blah blah $myheader
jeskel
18th January 2005, 05:34 AM
wow....
rep is on the way...
yeah!