Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
5 Tutorials in one thread!
#1
----------------------
5 Simple tutorials that relate to MyBB.
----------------------


Show Groups

Firstly create a new file in your root folder named 'showgroups.php'
Edit the file and add the following code and save it.

<?php 

define('IN_MYBB', 1); require "./global.php";

add_breadcrumb("Custom Usergroups", "showgroups.php"); 

eval("\$html = \"".$templates->get("showgroups")."\";"); 

output_page($html);

?>

Now go to your Admin Control Panel > Themes > Templates > Global Templates > and add a new template titled 'showgroups'.
In that template add the following code and save it.

</style>
<html>
<head>
<title>Current Usergroups</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><span class="smalltext"><strong>Current Custom Usergroups</strong></span></td>
</tr>
<tr>
<td class="trow1">

<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<br>
<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<br>
<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<div style="width: 48%; min-height:120px; border: 1px #0E8104 solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
    <table width="100%" cellspacing="0" cellpadding="5" border="0">
    <tr class="trow1">
    <td width="75%" border="0">
    <span><b>Usergroup</b></span><br />
    <span class="smalltext"><b>Leaders: </b>
     <a href="profile.php"><span style="color: white;">Add username(s) here</span></a><br /><a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a><br /><br />Description.</span>
    </td>
    <td width="25%" align="right" valign="middle">   
    <img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
    </td>
    </tr>
    </table>
    </div>
<br>
</td></tr></table>
{$footer}
</body>
</html> 

Then you can edit the code to the appropriate images, users and so on for each of your groups.


Upgrading Files from 1.6 to 1.8

We'll use Labrocca's Tabbed Menu from MyBBCentral.com for this tutorial.
Locate the following file, I'll be showing this example as from a cpanel. public_html/inc/plugins/ficons.php
Note: ficons.php will be whatever file you need updated!

Edit the file and find compatibility and change it from 16* to 18*

On 1.6 (before)
[Image: 45d66c9ba235e256e1e04f6e3590611b.png]

On 1.8 (after)
[Image: 5fa7ca90893e3cff69129170149ec739.png]

Save the file and check in the ACP to make sure it's working.

Still not working?
In the case it doesn't edit all the files related to that plugin and add 18*.
Then it should work, I'll admit I had to do it with a few plugins.


Alert AdBlock users about adblock extension

This short method will tell members using AdBlock to deactivate the extension in their browser.
Go to the Admin Control Panel > Themes > Templates > Theme Name > Header > Select who views it.
And then put this code in and save it.

<div class="YOUR_CLASS">Alerts!&nbsp;</div> // - You can remove this
<script>
(function() {
    var message = "Your Message to AdBlock Users!";
    var tryMessage = function() {
            setTimeout(function() {
                if(!document.getElementsByClassName) return;
                var ads = document.getElementsByClassName('YOUR_CLASS'),
                    ad  = ads[ads.length - 1];
  if(!ad
                    || ad.innerHTML.length == 0
                    || ad.clientHeight === 0) {
                    alert(message);
                 //window.location.href = 'http://comunidade.bf4brasil.com.br/member.php?action=register'; "//"  Redirect users to where you want - You need to remove "//"
                } else {
                    ad.style.display = 'none';
                }

            }, 1800);
        }
        if(window.addEventListener) {
            window.addEventListener('load', tryMessage, false);
        } else {
            window.attachEvent('onload', tryMessage);
        }
})();
</script>


Limit Signature Image Size in kilobyte


Go to your Root > Inc > Plugins > create a file named 'limitsign.php' and save it.
Then edit that file and add the following code.

<?php 
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

// Plugin info
function limitsign_info ()
{
    return array(
        "name"            => "limitsign",
        "description"    => "limitsign",
        "website"        => "limitsign",
        "author"        => "limitsign",
        "authorsite"    => "limitsign",
        "version"        => "limitsign",
        "guid"             => "limitsign",
        "compatibility" => "16*"
    );
}

$plugins->add_hook('usercp_start', 'signsize');
function signsize()
{
    global $mybb, $error;

    preg_match_all("/\[img(.*?)\](.*?)\[\/img\]/i", $mybb->input['signature'], $matches, PREG_SET_ORDER);

    $kbsizetot = 0;
    
    foreach ($matches as $img)
    {
    $kbsize = strlen(@file_get_contents($img[2]));
    $kbsizetot += $kbsize;
    }
    
    if (($kbsizetot > 350000) && ($mybb->input['action'] == "do_editsig")) {

    $error = inline_error("The sum of the size of the images exceeds the allowed limit of 350kb.");

    }    
}
?>

Change the value (currently 350000) to whatever you want it to be.
Additionally enter the error message you want and then save it.


Usergroups legend without using plugins


To begin with go to this template: Admin Control Panel > Templates & Style > Templates > theme of choice > Index Page Templates > index_boardstats.
Find {$whosonline} and replace with the following but filled in with your groups.

<tr>
<td class="tcat"><span class="smalltext"><strong>Usergroup Legend</strong></span></td>
</tr>
<tr>
<td class="trow1"><span class="smalltext">ADD YOUR USERGROUPS HERE</span></td>
</tr>

If you are having issues with whos online, readd the code for it which is > {$whosonline}
Check out all my submissions here - click me
MyBB support at it's finest. 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)