MyBB Source
[Awards System] Split up awards - Printable Version

+- MyBB Source (http://mybbsource.com)
+-- Forum: Customization (/forum-9.html)
+--- Forum: Tutorials (/forum-40.html)
+--- Thread: [Awards System] Split up awards (/thread-2835.html)

Pages: 1 2 3 4 5


[Awards System] Split up awards - Nickman - 11-01-2009 06:18 AM

If you are like most people, you want only a few awards per line and then have a line break to break them up. This will make that happen for you 001_smile

Open inc/plugins/awards.php, replace this:

PHP Code:
function awards_post()
{
    global 
$templates,$mybb,$db,$awards;
    if (
$mybb->settings['enableawards'] == AND $mybb->settings['awards_on_postbit'] !='0')
    {
        
$getAwards=$db->query("SELECT g.*, a.* FROM ".TABLE_PREFIX."awards_given AS g LEFT JOIN ".TABLE_PREFIX."awards AS a ON(g.award_id=a.id)");
        
$count=array();
        while (
$award=$db->fetch_array($getAwards))
        {
        
$to=$award['to_uid'];
            if ((
$count[$to] <= $mybb->settings['awards_on_postbit']) OR $mybb->settings['awards_on_postbit'] == '-1')
            {
                
$awards[$to].="<a href='award.php?id={$award[gid]}' title='{$award[name]}'><img src='{$mybb->settings['bburl']}/images/awards/$award[image]' title='award image' border='0'/></a> &nbsp;";
            }
            
$count[$to]++;
        }
    }


with this:
PHP Code:
function awards_post()
{
    global 
$templates,$mybb,$db,$awards;
    if (
$mybb->settings['enableawards'] == AND $mybb->settings['awards_on_postbit'] !='0')
    {
        
$getAwards=$db->query("SELECT g.*, a.* FROM ".TABLE_PREFIX."awards_given AS g LEFT JOIN ".TABLE_PREFIX."awards AS a ON(g.award_id=a.id)");
        
$count=array();
        
$i=1;
        while (
$award=$db->fetch_array($getAwards))
        {
            
$to=$award['to_uid'];
            if ((
$count[$to] <= $mybb->settings['awards_on_postbit']-1) OR $mybb->settings['awards_on_postbit'] == '-1')
            {
                
$awards[$to].="<a href='award.php?id={$award[gid]}' title='{$award[name]}'><img src='{$mybb->settings['bburl']}/images/awards/$award[image]' title='award image' border='0'/></a> &nbsp;";
            }
            if (
$i == NUMBER_PER_LINE_HERE)
            {
                
$awards[$to].="<br />";
                
$i=1;
            }
else
{
$i++;
}
            
$count[$to]++;
        }
    }


Make sure you change NUMBER_PER_LINE_HERE into a number, then save and done!


RE: [Awards System] Split up awards - Ajdija - 11-01-2009 08:10 AM

great tut Nickman! thx!


RE: [Awards System] Split up awards - Chrissy - 11-02-2009 05:08 AM

Thanks for this 001_smile


RE: [Awards System] Split up awards - alvarorojas4 - 11-07-2009 09:39 PM

OMG
Thanks a lot for this 001_smile


RE: [Awards System] Split up awards - Skiilz - 11-25-2009 02:49 AM

Thank you nick. I was looking for this.


RE: [Awards System] Split up awards - telters - 01-29-2010 02:12 PM

Thanks!


RE: [Awards System] Split up awards - butterfly44 - 01-30-2010 01:04 PM

Sweeet. Heart thank u


RE: [Awards System] Split up awards - santanu18 - 02-01-2010 05:17 AM

Thanks a lot.


RE: [Awards System] Split up awards - Devilson - 02-04-2010 09:29 PM

Is this for labroccas plugin?


RE: [Awards System] Split up awards - Mr-Trainor - 04-04-2010 11:47 PM

(02-04-2010 09:29 PM)Devilson Wrote:  Is this for labroccas plugin?

It's for nickman's awards plugin 001_smile
--
Thanks for this! I'm gonna change it now Big Grin