MyBB Community Forums

Full Version: Help modifying output_page function to include PHP files.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I was not sure whether to post this under Code Modifications or Templates but it seemed to fall best under Code Modifications.

I have been working on integrating MyBB with my site, and have gotten quite far, however I still am having some issues. I am trying to find out if there is an easier way to do what I have already done.

I have 3 PHP files (header.php, leftsidebar.php, and footer.php) which need to be included into MyBB each time the page loads. Because MyBB does not allow PHP in templates I had to resort to modifying each page (index.php, usercp.php etc.) to include these files, which surround the forum.

I have done this like this:

include 'header.php';
include 'leftsidebarwide.php';

eval("\$index = \"".$templates->get("index")."\";");
output_page($index);

include 'footer.php';

Where the output_page is the part that displays the MyBB template and the includes are the files being included. I have also removed everything from the header and footer templates in MyBB.

Most pages display just fine using this method, however I did this to every output_page I could find, and it took quite some time. Now that I think about it, there probably is a place where I can place the include code that will include it to every output_page. Does anyone know in what file and where I could do this?

Another part of the problem I am running into is that some page elements are not displaying, such as the avatar on a member's profile. After moving the include code around a bit, I was able to get the avatar to display, but then the breadcrumb stopped working. I am guess this is because some things before the php include are getting left behind and are never loaded.

Is there any place I can put the include code so that it would be included on all pages (without affecting things on the page)? Huh

Sorry if this question is confusing. I probably made it that way by making it so long! Confused

Thanks for taking the time to read it!
Yeah, MyBB's template system won't go well with what you're doing.
Is there any particular reason why it must be in a separate PHP file, rather than using the templates system?

Otherwise, if you must, you can try the PHP in Templates plugin.
I need it in a separate PHP file because I am using the MyBB Integration Class/SDK for integrating into the site. Since that needs PHP to run then I must be able to use PHP. I also have other PHP scripts which I am using too. Also I have many other pages on my site which I don't want to convert to MyBB's template system. I would prefer to just use the PHP files I already have...

I tried the PHP in Templates plugin but I always got a memory allocation error or something like that. I tried increasing the memory limit in my php.ini but that did not help either.
This is the very same situation I am in as miimario's. I would prefer using my own php header, sidebar and footer that I already have my own to using myBB header. It would save me time to include the header in the myBB that is consistent in design throughout the site.

I have just installed myBB and it works great. But, currently I'm working on figuring out how to include my existing footer and header via php include in myBB.

Anyone knows the tip or code; that'd be much appreciated!
@artist19 - I responded to your thread over here. http://community.mybboard.net/thread-650...67472.html
I finally did get something to work.

@Yumi - I also finally did get the PHP in Templates plugin working, not for this, but for something else. It works great for IF statements Smile