|
|
| Author |
Message |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 12419
Location: Harbinger, NC, U.S.A.
|
Posted: June 23rd 2008, 11:22 am Post subject: Including a File in phpBB 3's PHP Files |
|
|
Hey all,
This is probably pretty simple, but it's escaping me. So, I thought I'd ask for help.
Let's say that you have a file called include.inc that you want to include in the footer of your phpBB 3. But, you don't want to make the change in overall_footer because you have a lot of styles installed and just want to have to make one change. (This may not be the best way to do it, but it's the way you want to do it, anyway ).
In phpBB 2, you could add "include("include.inc");" to page_tail.php, but when I try to add it in a phpBB 3 file I get cannot modify header errors. If anyone knows what the answer is, as far as how I can get it in there, that'd be great.
I appreciate your time.
Thanks,
Patrick _________________ Patrick O'Keefe - phpBBHacks.com Administrator
Author, Managing Online Forums (New Book)
Have a suggestion or a bit of feedback relating to phpBBHacks.com? Please contact me!
User Guidelines - phpBBHacks.com Awards - Featured phpBB - About Us - Supported Sites - Utilities
phpBB 2 Tutorials: Installing phpBB Hacks - Installing a New Template |
|
| Back to top |
|
 |
eviL<3
Not So New User
Joined: 25 Jun 2006
Posts: 65
|
Posted: June 23rd 2008, 11:33 am Post subject: |
|
|
This is a little tricky.
In phpBB 2.0 the template code is output right away. In phpBB 3.0 this is different, it's only output at the very end. This means that you are not allowed to output anything before it and therefore need to use the template system.
My suggestion would be to assign your stuff as a template variable, then you can add that to all of your styles and never have to adjust them again. Let me give you an example.
"footer.inc":
| Code:
|
<?php
echo 'I\'m some test stuff...';
?>
|
Now we have to add the following to page_footer() in functions.php:
| Code:
|
// begin with output buffering
ob_start();
// include our file
include('path/to/footer.inc');
// get contents of the output buffer and delete it
$footer_stuff = ob_get_clean();
// assign it as a template variable
$template->assign_var('FOOTER_STUFF', $footer_stuff);
|
Now all you have to do is add this to the template file:
I hope that makes sense (and works ). _________________ phpBBModders |
|
| Back to top |
|
 |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 12419
Location: Harbinger, NC, U.S.A.
|
|
| Back to top |
|
 |
Semi_deus
New User
Joined: 23 Jun 2008
Posts: 6
Location: the Netherlands
|
Posted: June 24th 2008, 4:02 am Post subject: |
|
|
| Patrick wrote:
|
Hey Igor,
Thanks for that. I appreciate your help and time.
Really, I have to do it without editing any styles, not even the slighest change. Is there any way for that to happen?
Thanks,
Patrick
|
I don't think that could be possible..
The html needs to be putten somewhere, and I think this is a small a change as it gets. |
|
| Back to top |
|
 |
Marian
Not So New User
Joined: 08 Apr 2007
Posts: 63
|
Posted: June 24th 2008, 5:18 am Post subject: Re: Including a File in phpBB 3's PHP Files |
|
|
| Patrick wrote:
|
|
But, you don't want to make the change in overall_footer because you have a lot of styles installed and just want to have to make one change.
|
You could choose to install only one template and a lot of themes to go with it. Then you'd only have to make one change in the template file and it would affect all your styles at once. |
|
| Back to top |
|
 |
Semi_deus
New User
Joined: 23 Jun 2008
Posts: 6
Location: the Netherlands
|
Posted: June 24th 2008, 8:10 am Post subject: Re: Including a File in phpBB 3's PHP Files |
|
|
| Marian wrote:
|
| Patrick wrote:
|
|
But, you don't want to make the change in overall_footer because you have a lot of styles installed and just want to have to make one change.
|
You could choose to install only one template and a lot of themes to go with it. Then you'd only have to make one change in the template file and it would affect all your styles at once.
|
Thats not possible either is it? Well, atleast not with phpbb3. |
|
| Back to top |
|
 |
Marian
Not So New User
Joined: 08 Apr 2007
Posts: 63
|
Posted: June 24th 2008, 9:00 am Post subject: |
|
|
| Yes it is, I have only subsilver2 and prosilver templates installed and more than 20 themes and imagesets. Most mods only change the template files so I only have to do those changes twice instead of 20+ times. |
|
| Back to top |
|
 |
Semi_deus
New User
Joined: 23 Jun 2008
Posts: 6
Location: the Netherlands
|
Posted: June 24th 2008, 10:01 am Post subject: |
|
|
Ah, I didn't understand your previous post
But that won't solve Patricks problem, I think, since he is more
concerned about the change, then how often it needs to be done. |
|
| Back to top |
|
 |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 12419
Location: Harbinger, NC, U.S.A.
|
|
| Back to top |
|
 |
Ricky_Racer
Dedicated User

Joined: 19 Jul 2003
Posts: 1385
Location: Middle of Nowhere, USA
|
Posted: June 25th 2008, 7:31 am Post subject: |
|
|
If isn't too complicated of html, (JavaScript), why not just add it in here ? (./includes/functions.php)
| Code:
|
echo ' <div id="page-footer">';
echo ' Powered by phpBB © 2000, 2002, 2005, 2007-2008 <a href="http://www.phpbb.com/" target="_phpbb">phpBB Group</a>';
echo ' </div>';
echo '</div>';
echo '</body>';
echo '</html>';
|
Wouldn't that then make it a part of the function, ?
Therefore, no need to edit overall_footer.html. Or am I completely lost in left field ? (What can I say it's baseball season)  |
|
| Back to top |
|
 |
|