MyBB Community Forums

Full Version: Help with including header/footer on MyBB pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

First off I want to say that this is the first time I have tried to integrate a site with MyBB so I'm sorry if the answer to this question is a obvious but I haven't been able to find the answer so any help is appreciated. Ok on to the question Smile

I have my site setup like this:

root/index.php ..................... (my custom homepage)
root/php .............................. (folder containing php includes)
root/forum ........................... (folder containing mybb)
etc.

I have my header.php (links to css and js files etc.), navigation.php (custom menu) and footer.php (custom footer) stored in the php folder.

The header and footer both make use of MyBB variables (e.g. mybb->user['avatartype']) and only works if I include this in my header.php file.

define("IN_MYBB", 1);
require_once "/forum/global.php";
require_once "/forum/inc/class_parser.php";

On my custom homepage everything works as expected, however when I use the Dynamic Header and Footer plugin to include my header.php, navigation.php and footer.php into any MyBB page I get an error that global.php can not be found (error is: failed to open stream: No such file or directory).

I think it has something to do with the file path referencing global.php and that it should be an easy fix however I have tried many combinations of file paths (both relative and absolute) and still get the same error.

How do I include global.php in my header.php file so that it will work on both my custom homepage and all MyBB pages?


If you need me to clarify any part of my question/setup please let me know.

Ok so I figured out how to find global.php on all pages that have my header included by using:

define('ROOTPATH', $_SERVER['DOCUMENT_ROOT']."iwi");
require_once ROOTPATH."/forum/global.php";

I have checked that the file path is correct for both my custom homepage and mybb pages by using php file_exists. However when I use this code I get an error that stops any page from loading, error is below:

( ! ) Fatal error: Maximum execution time of 20 seconds exceeded in C:\wamp\www\iwi\forum\inc\class_error.php on line 145
Call Stack
# Time Memory Function Location
1 0.0007 152376 {main}( ) ..\index.php:0
2 0.0013 157904 include( 'C:\wamp\www\iwi\php\header.php' ) ..\index.php:14
3 0.0028 325080 require_once( 'C:\wamp\www\iwi\forum\global.php' ) ..\header.php:13
4 0.0465 2464816 pluginSystem->run_hooks( ) ..\global.php:1045
5 0.0465 2465336 DynamicHeaderFooter_global_end( ) ..\class_plugins.php:139
6 0.0465 2465384 DynamicHeaderFooter_Process( ) ..\DynamicHeaderFooter.php:158
7 0.0465 2465592 file_get_contents ( ) ..\DynamicHeaderFooter.php:141
8 120.0480 2467256 errorHandler->error( ) ..\DynamicHeaderFooter.php:141

Any ideas on how to fix this?