MyBB Community Forums

Full Version: [Tutorial] Updated: True integration with Coppermine and MyBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9
Regarding my previous tutorial for integrating Coppermine into MyBB at http://community.mybb.com/thread-76482.html, I have modified parts of it to be implemented as its own Coppermine plugin. No more modifying the sample plugin or plugin file edits.

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

This integration requires:

One CPG core file edit
Tweaks to CPG template of choice
Install and configure included Coppermine plugin
Upload included wrapper file
Two new MyBB templates for the top and bottom of the wrapper

==========================
Step 1. Getting started
==========================

Set your current Coppermine installation to use a default unmodified theme (one that you will not be modifying for integration). This will make it easier to install and configure the plugin without the theme messing up the layout.

Make sure MyBB and Coppermine are properly bridged and the features working as expected.

Backup <CPGROOT>\includes\init.inc.php

==========================
Step 2. Coppermine Core File Edits for 1.5.x
==========================


Edit <cpgroot>\includes\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; 
$globalpost = $_POST; 
$globalget = $_GET; 

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 three lines similar to $_COOKIE=$globalcookie (cookie, post and get) line in the wrapper file below

==========================
Step 3. Template Edits for Coppermine 1.5.x
==========================


In my case, I edited the template.html file of the Classic theme. 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.

Depending on how complex the theme is, you may just want to backup the Classic theme and modify that one as it is a simple theme and template which will make initial edits easier. You can always apply these edits to another theme once you have the integration working.

==========================
Step 4. CSS Edits for Coppermine 1.5.x
==========================


To match the overall look, you need to edit the Classic theme's 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 looking match.

==========================
Step 5. Installing Coppermine Plugin for 1.5.x
==========================


Upload the contents of the included \Coppermine\plugins folder to you <cpgroot>\plugins\ folder. This should be a folder called mybb_wrapper with 3 files in it.

From your Coppermine plugin manager (usually linked in the Config > General Settings > Plugins > Manage Plugins) click the Install icon next to the MyBB Wrapper plugin. This will install the plugin into Coppermine and take you to the plugin configuration page.

Enter the appropriate data using the default paths as an example. Click the OK button.

==========================
Step 6. Wrapper for MyBB 1.4.x/1.6.x
==========================

I have include my copy of the wrapper in the zip file 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. This is the only edit required for basic functionality.

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.

There is some navigation language when adding the breadcrumb, you can edit that if you like.

Upload this file to your <CPGROOT> folder

==========================
Step 7. Templates for MyBB 1.4.x or 1.6.x
==========================

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> 

==========================
Step 8. Clean Up existing custom header/footer for Coppermine 1.5.x
==========================


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.

All Done!
==========================


You can check out how it all is working on my site, listed in my sig line.

UPDATE on 10/8/2011
There is an issue if your host still have Magic Quotes enabled (you really should ask them to disable it and if your site breaks, update it to not use magic_quotes and code it correctly)

So there are minor edits required to make it work (Step 2 has been updated). The above tutorial has been updated as has the attached zip package.

To upgrade, just redo Step 2 above and upload the new cpg_mybb_wrapper.php file.
Wow that is amazing i love the way it all is fitted in nicely to the existing theme of the forums i may play on my local host to see if i can get it running although i think coppermine site is down at the moment
As i was thinking of seeing if there was a update to the gallery.
i noticed the coppermine site was down as well
It seems it is working now
Hi pavement,

Thanks for the updated tutorial. However I still failed with the following errors:

Parse error: syntax error, unexpected '<' in /home/cubictalk/cpgallery/cpg_mybb_wrapper.php on line 70

I had difficulties in following Step 6. Wrapper for MyBB 1.4.13. I choose the use Classic theme from Coppermine and edited with the following in the cpg_mybb_wrapper.php


/***********************************************************
Start User Edit (2 of 2)
*
**********************************************************/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{CUSTOM_HEADER}
<div id="cpg_main_block">
<a href="index.php">
<img id="logo" src="themes/classic/images/coppermine-logo.png" alt="Logo" />
</a>
<div id="header">
<h1>{GAL_NAME}</h1>
<h3>{GAL_DESCRIPTION}</h3>
<p id="sysmenu">{SYS_MENU}</p>
<p id="submenu">{SUB_MENU}</p>
</div>
<div class="clearer"></div>
{ADMIN_MENU}
{MESSAGE_BLOCK}
{GALLERY}
</div>

$headerinclude .= '<link rel="stylesheet" href="themes/classic/style.css" type="text/css" />';

/***********************************************************
End User Edit
***********************************************************/
{CUSTOM_FOOTER}


Could you please highlighten me? Many thanks!
You do not edit the cpg_mybb_wrapper.php file except for the variables in between the

/***********************************************************
Start User Edit 
***********************************************************/

and the

/***********************************************************
End User Edit 
***********************************************************/

sections (two of them).

The instructions for Step 3 say to

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

and does not say to put the entire template code into the wrapper file. However, in Step 6, it does say to append that javascript and css info from the template into the $headerlinclude variable.

for example, if your template has a line such as <script type="text/javascript" src="http://community.mybb.com/jscripts/prototype.js?ver=1600"></script>, you would remove it from the template.html file and put it in the wrapper file as such

$headerinclude .= '<link rel="stylesheet" href="themes/classic/style.css" type="text/css" />';
$headerinclude .= '<script type="text/javascript" src="http://community.mybb.com/jscripts/prototype.js?ver=1600"></script>';

of course that is only an example, so please do not simple copy this code. If you have no other code, or the existing headerinclude content is not present in your template you can comment out the variable by putting two slashed in front of it ( // )
Hi pavement,

Thanks for the explanation. However, I still have difficulty in putting the template to the wrapper. Basically I will use the coppermine Classic theme to try. Could you be kind enough to help demonstrate extracting it to the wrapper for me to appreciate? Attached below is the full template file.

Thanks in advance for your help!
here is the template.html from my Classic theme after modiufying it

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  {CUSTOM_HEADER}
  <table width="100%" border="0" cellpadding="1" cellspacing="1">
    <tr>
      <td valign="top" style="border: 1px solid #666666;background-color:#EAEAEB;">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="100%" align="center">
              <br /> {SYS_MENU} <br /> {SUB_MENU}
            </td>
          </tr>
        </table>
        <img src="images/spacer.gif" width="1" height="15" alt="" />
        <br />
        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left" valign="top">
              {ADMIN_MENU}
              {GALLERY}
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  {CUSTOM_FOOTER}

and you should not have to edit the second section of cpg_mybb_wrapper.php, only the MYBB_ROOT in section 1
This is awesome! Thanks for this tutorial!!
Hi pavement,

I was diverted to another job and come back to work on the coppermine integration again. I deleted all the files and redo it from fresh. However, I could not go further once activating the Wrapper plugin. The screen shows errors:

File: inc/functions.php (Line no. 1119)
Invalid argument supplied for foreach()

It seems I encountered the same problem as some users before. Don't know if they have solve the problem and how to do it..

Regards
Pages: 1 2 3 4 5 6 7 8 9