Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 12391
Latest: alicemgns01
New This Month: 3
New This Week: 0
New Today: 0
Stats
Total Posts: 40375
Total Topics: 7106
Most Online Today: 146
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 57
Total: 57

Author Topic: Keep a certain badge in 1st position?  (Read 2686 times)

0 Members and 1 Guest are viewing this topic.

Offline 200mV

  • Newbie
  • *
  • Posts: 18
    • View Profile
Keep a certain badge in 1st position?
« on: May 27, 2014, 10:59:43 am »
Is there an easy way to keep a certain badge in the 1st position when badges are being shown on the forum under your avatar?

I made a custom badge called "Paid Member" and if possible, I would like that one (when applicable) to be the first one being shown always...

Is this possible?

Thanks!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15177
    • View Profile
Re: Keep a certain badge in 1st position?
« Reply #1 on: May 27, 2014, 12:40:40 pm »
You can try this code unsted.
Just change the $firstBadgeID = 111111;
To the id of the badge you want first

Find
Code: [Select]
function Badges_DisplayBadges($memberID = 0, $order = 'recent', $maxToShow = 5)
{
global $smcFunc, $modSettings, $boardurl;

if (empty($modSettings['badgeawards_enable']))
return;

    if (empty($memberID))
        return; 
       
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
       
$badgesCache = array();
if (($badgesCache = cache_get_data('badge_display_' . $memberID, 60)) == null)
{

$result = $smcFunc['db_query']('', "
SELECT
b.id_badge, b.title, b.image, b.enabled
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
WHERE l.id_badge = b.id_badge AND l.ID_MEMBER = $memberID
ORDER BY l.id_log DESC
LIMIT  $maxToShow
");
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$badgesCache[] = $row;

}

Code: [Select]


function Badges_DisplayBadges($memberID = 0, $order = 'recent', $maxToShow = 5)
{
global $smcFunc, $modSettings, $boardurl;

if (empty($modSettings['badgeawards_enable']))
return;

    if (empty($memberID))
        return; 
       
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
       
$badgesCache = array();
if (($badgesCache = cache_get_data('badge_display_' . $memberID, 60)) == null)
{

$result = $smcFunc['db_query']('', "
SELECT
b.id_badge, b.title, b.image, b.enabled
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
WHERE l.id_badge = b.id_badge AND l.ID_MEMBER = $memberID
ORDER BY l.id_log DESC

");
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$badgesCache[] = $row;

}

$firstBadgeID = 111111;


$finalBadges = array();
$count = 0;
// Get first badge
foreach($badgesCache as $row)
{
if ($badgesCache['id_badge'] == $firstBadgeID)
    {
        $finalBadges[] = $row;
        $count++;
        break;
    }
}



foreach($badgesCache as $row)
{
if ($badgesCache['id_badge'] != $firstBadgeID)
    {
        $finalBadges[] = $row;
        $count++;
       
        if ($count > $maxToShow)
            break;
    }
}

$badgesCache = $finalBadges





Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline 200mV

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Keep a certain badge in 1st position?
« Reply #2 on: May 28, 2014, 02:47:15 pm »
Thanks much!

I'll give it a shot and let ya know how it goes...

A+ service, thanks!

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
1614 Views
Last post October 16, 2011, 03:01:51 pm
by SMFHacks
1 Replies
2004 Views
Last post June 07, 2012, 05:40:14 pm
by SMFHacks
1 Replies
3718 Views
Last post July 26, 2012, 10:22:15 pm
by SMFHacks
1 Replies
2303 Views
Last post April 08, 2014, 04:44:53 pm
by SMFHacks
2 Replies
738 Views
Last post January 06, 2020, 08:52:31 pm
by slizzie1986

+- Recent Topics

Feature Request for Classifieds by SMFHacks
October 21, 2020, 10:30:17 pm

[Mod] ezPortal by Alistair
October 18, 2020, 11:00:17 am

ezPortal homepage on mobile browser (SMF 2.1 RC3) by Alistair
October 18, 2020, 05:47:56 am

Search box? by Shades
October 10, 2020, 01:13:00 pm

Attachment images Upsidedown or Sideways by Shades
September 27, 2020, 07:01:31 am

Installing Awesome Post Ratings on non-default theme by SMFHacks
September 26, 2020, 11:54:25 pm

Listings page image not showing by Shades
September 23, 2020, 03:05:06 pm

prettyurls - TroubleShooting.wiki by SMFHacks
September 22, 2020, 04:24:47 pm

Quality of images after import by SMFHacks
September 05, 2020, 10:21:44 am

How do I download gallery images? by CWVRV
August 30, 2020, 11:50:07 pm

Powered by EzPortal