| Author |
Post |
|
|
#1 Wed Apr 11, 2007 4:21 am
|
|
Member
Registered: Apr 2007
Posts: 13
|
I'm working UseBB into a site of mine and I use PHP includes for the main site header and menu on all the regular pages in my site. I'd like to use those same includes in the Template for UseBB. How exactly do I do that? I attempted: <?php include('../includes/header.php'); ?>and {php} include('../includes/header.php'); {/php}But neither shows the header. I'm sorry if this is a stupid request, but I'm rather PHP challenged. Any help anyone here can offer would be greatly appreciated. Thank you, Dawn
|
|
|
#2 Wed Apr 11, 2007 4:34 am
|
|
Member
Registered: May 2005
Posts: 294
Location: 98671
|
You talking adding something similar to what you see on this forum, at the very top above UseBB logo. Or integrating into your site. « Last edit by William on Wed Apr 11, 2007 4:39 am. »
|
|
|
#3 Wed Apr 11, 2007 8:17 am
|
|
Developer
Registered: Apr 2004
Posts: 2202
Location: Belgium
|
UseBB des not support including files in the templates. You could try including them in global.tpl.php and capture the output using an output buffer (using ob_start() etc) and place the result in the right template by splitting the template's string.
|
|
|
#4 Wed Apr 11, 2007 12:21 pm
|
|
Member
Registered: Apr 2007
Posts: 13
|
First of all, thank you for the quick response!
Yes, it's something I want to integrate into the template of UseBB.
Dietrich, it sounds like you're on the right track there. So I would include the files as normal in the global.tpl.php? Then I would capture the output using an output buffer that would split the string? I'm assuming you mean, I would add something like this:
.... interrupt template code';
capture the output here?
echo'resume template code....
Exactly how would I use the using "ob_start()" to do that. I'm sorry, I really am PHP challenged. I am really grateful for your assistance.
Dawn
|
|
|
#5 Wed Apr 11, 2007 12:43 pm
|
|
Developer
Registered: Apr 2004
Posts: 2202
Location: Belgium
|
Use ob_start(), then include the file, put the contents in a string using ob_get_contents() and stop the buffer using ob_end_clean(). You may then insert the string variable into the template. Don't use echo() or print(), it has no effect.
|
|
|
#6 Wed Apr 11, 2007 1:33 pm
|
|
Member
Registered: Apr 2007
Posts: 13
|
Does one of the template files have an example I could look at to see exactly how that works?
Dawn
|
|
|
#7 Wed Apr 11, 2007 2:53 pm
|
|
Developer
Registered: Apr 2004
Posts: 2202
Location: Belgium
|
UseBB does not contain any of these hacks, but you could do like the following: <?php
// ...
ob_start(); include(ROOT_PATH.'../something.php'); $include = ob_get_contents(); ob_end_clean();
// ...
$template['something'] = ' foo {bar} '.$include.' foo {bar}';
?> I hope you understand what I mean, the templates are just string array values which you could split and insert a variable ($include) in it.
|
|
|
#8 Wed Apr 11, 2007 3:07 pm
|
|
Member
Registered: Apr 2007
Posts: 13
|
I think I'm getting it. I swear, I wish I understood scripting languages better. I'll give it a shot and see what happens. I really do appreciate your help, Dietrich. I love UseBB ... it rocks!
Dawn
|
|
|
#9 Thu Apr 12, 2007 12:24 am
|
|
Member
Registered: Apr 2007
Posts: 13
|
EUREKA! Thank you so much Dietrich! Through a little trial and error, my PHP-challenged self finally got it to work. Your assistance is much appreciated!
Dawn
|
|
|
#10 Mon May 07, 2007 2:11 pm
|
|
Member
Registered: May 2007
Posts: 7
Location: Nigeria
|
Dawnrae, my trial & error not working yet. pls let me learn know how you are able to fix this. (templates & pages edited) Olufemi
|
|
|
#11 Mon May 07, 2007 2:35 pm
|
|
Member
Registered: Apr 2007
Posts: 13
|
I'm at work right now, but I'll send you some code examples when I get home this evening.
Dawn
|
|
|
#12 Tue May 08, 2007 2:04 am
|
|
Member
Registered: Apr 2007
Posts: 13
|
Okay, here's how I got it to work. In global.tpl.php, below the statement if ( !defined('INCLUDED') ) exit();I placed the following: ob_start(); include(ROOT_PATH.'../includes/header.php'); $my_header = ob_get_contents(); ob_end_clean(); Then, within the template, in the area I wanted the header to appear, I did this: <!-- HEADER BEGINS --> '.$my_header.' <!-- HEADER ENDS -->
Hope that helps! Dawn
|
|
|
#13 Tue May 08, 2007 9:42 am
|
|
Member
Registered: May 2007
Posts: 7
Location: Nigeria
|
It works perfectly well. Thanks very much. I appreciate your help. olufemi
|
|
|
#14 Tue May 08, 2007 12:02 pm
|
|
Member
Registered: Apr 2007
Posts: 13
|
No problem. Glad to be of help.
Dawn
|