MyBB Community Forums

Full Version: [Tutorial] True integration between MyBB and Coppermine 1.5
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
So I finally figured out how to truly integrate Coppermine 1.5 with MyBB 1.4.13 (should work fine with MyBB 1.6 as well). This is a full MyBB header and footer with user status/PM, etc. The only thing I can not get working right now is QuickLogin

It "only" requires:

one CPG core file edit
tweaks to CPG template of choice
edit or create new CPG plugin (I simply edited the sample plugin)
A CPG-MyBB wrapper PHP file that I created, which is very similar to any custom page
Two new MyBB templates for the top and bottom of the wrapper

==========================
CPG Edits for 1.5.8
==========================

Edit <cpgroot>\inclulde\init.inc.php
Here you can either disable strict mode, but that opens up all superglobals that CPG is trying to lock out for security, or make a copy of the $_COOKIE variable before that happens and let CPG work as it originally does. I chose the latter method

after:
// Set $strict to false to make the superglobals available
$strict = TRUE;

add:
$globalcookie = $_COOKIE;

This will store the $_COOKIE variables for later use in the MyBB code. Without this edit or setting $strict = FALSE, MyBB will not have access to the server cookies needed to support MyBB user data when wrapping in CPG 1.5

If you use the $strict=FALSE; option instead, you should still add the $globalcookie line, or if not, comment out the $_COOKIE=$globalcookie line in the wrapper below

==========================
Template Edits for 1.5.8
==========================

In my case, I edited the template.html file of the theme I wanted to use. In template.html, remove all the content between <DOCTYPE> and {CUSTOM_HEADER} and all the content below {CUSTOM_FOOTER}

While you are there, correct any layout issues like missing closing tags, etc.

If there is any javascript or stylesheet info in the template.html header, retain that info for later use.

==========================
CSS Edits for 1.5.8
==========================

To match the overall look, you need to edit the style.css file as well. For my site, I had to modify .tableh1, .tableh1compact and .navmenu to include the background and color settings from MyBB's .thead. You may need to adjust the path to background images depending on your folder setup.

there may be other minor edits you need to make the style.css file to get a better match.

==========================
Sample Plugin Edits for 1.5.8
==========================

Edit the <cpgroot>\plugins\sample\codebase.php file

Comment out first filter line and add the new one shown below. You can change the 'test' to whatever function you want, just be consistent when making the edits below
// Add a filter for the gallery header
$thisplugin->add_filter('gallery_header','sample_header');

Edits
// Add a filter for the gallery header
//$thisplugin->add_filter('gallery_header','sample_header');
$thisplugin->add_filter('template_html','test');

After the last filter add the test function:
$thisplugin->add_filter('plugin_block','sample_block_mgr');

function test($html)
{
	require_once('../photos/cpg_mybb_wrapper.php');
//	return str_replace('{CUSTOM_HEADER}', $header, $html);
	$html = str_replace('{CUSTOM_HEADER}', $cpg_main_top, $html);
	return str_replace('{CUSTOM_FOOTER}', $cpg_main_bottom, $html);

}

==========================
Wrapper for MyBB 1.4.13
==========================

I have attached my copy of the wrapper as I need it. There are several edits you would need to make...

You may need to modify the globals line. Most entries are required, but as you can see, there are some variables you wont need, like the $adserver_* ones as those are for my banner ads that are generated via a separate plugin. If you have a plugin that applies other variables to the templates, you will need to add those to this globals list.

Update the path in the MYBB_ROOT definition

Remember the template.html <head> items you saved when modifying that file? Now is the time to add those into the $headerinclude variable at the bottom of the wrapper. Otherwise you will loose the features of the CPG theme you are trying to implement. Do NOT overwrite the $headerinclude, but append to it.

If you set the init.inc.php file to use $strict=FALSE, comment out the $_COOKIE=$globalcookie line unless you added the globalcookie line to init.inc.php above.

Upload this file to your <CPGROOT> folder

==========================
Templates for MyBB 1.4.13
==========================

Create two new templates called cpg_main_top and cpg_main_bottom. I am using the default templates, so adjust to fit your template needs. I just grabbed the parts I needed from the index template.

Top:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
<script type="text/javascript">
<!--
	lang.no_new_posts = "{$lang->no_new_posts}";
	lang.click_mark_read = "{$lang->click_mark_read}";
// -->
</script>
</head>
<body>
{$header}

Bottom:
<br style="clear: both" />
{$footer}
</body>
</html>

==========================
Clean Up existing custom header/footer for 1.5.8
==========================

If you have already specified a custom header and/or footer in the CPG config, empty those values as the wrapper will now handle it all.

==========================
Enable Sample Plugin for 1.5.8
==========================

In the CPG config page, install the sample plugin.


==========================


You can check out how it all is working on my site, listed in my sig line.
BTW, you do need to still use the CPG Bridge system and that should be working before trying the above stuff. Do not forget to backup your CPG files (init.inc.php and sample\codebase.php) before editing.

EDIT: I have updated the attached file so that archive link and navigation breadcrumbs work.
it works but with error:

Warning [2] Invalid argument supplied for foreach() - Line: 275 - File: inc/class_core.php PHP 5.2.9 (Linux)

I have checked all files and edits over and over again...
that is a MyBB issue. My code does not use the strip_slashes_array() function so its something in your files.

What version of MyBB are you using? What version of Coppermine?
thanks for the tut Big Grin

its working great on my dev site
you are welcome, glad it is working for you. are you on MyBB 1.6? I expect it to work fine on that version, but have not tested it myself.
(2010-09-22, 03:57 PM)pavemen Wrote: [ -> ]that is a MyBB issue. My code does not use the strip_slashes_array() function so its something in your files.

What version of MyBB are you using? What version of Coppermine?

I use Mybb 1.6 with Coppermine 1.5.8.
I have no problems with mybb the error comes up when i visit the gallery.
(2010-09-23, 03:00 PM)pavemen Wrote: [ -> ]you are welcome, glad it is working for you. are you on MyBB 1.6? I expect it to work fine on that version, but have not tested it myself.

yep on mybb 1.6 and latest coppermine
(2010-09-24, 06:56 AM)DJNilo Wrote: [ -> ]
(2010-09-22, 03:57 PM)pavemen Wrote: [ -> ]that is a MyBB issue. My code does not use the strip_slashes_array() function so its something in your files.

What version of MyBB are you using? What version of Coppermine?

I use Mybb 1.6 with Coppermine 1.5.8.
I have no problems with mybb the error comes up when i visit the gallery.

can you provide the URL (here or via PM)
I was looking for this, will test it in full, and maybe if I have time will take a look at the code for the quick login Wink

Will test at Coppermine (latest version) and MyBB 1.6
i have not had time to look much into the quick edit, but i bet its something very simple i just overlooked. if i can find some time, i will start looking again
Pages: 1 2 3 4