Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12388
Latest: Rands
New This Month: 5
New This Week: 0
New Today: 0
Stats
Total Posts: 40310
Total Topics: 7100
Most Online Today: 97
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 2
Guests: 41
Total: 43

Author Topic: Badges not displaying  (Read 5745 times)

0 Members and 1 Guest are viewing this topic.

Offline VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Badges not displaying
« on: July 25, 2015, 07:34:39 am »
I have a general question first, is there a help file that shows all of the Action Labels or "Action" or are all of these hard coded already? 

This may be the problem again with the Reseller theme, but non of the badges are showing up http://www.vapeshopforum.com/index.php?topic=5.0  These are the list of badges http://www.vapeshopforum.com/index.php?action=badgeawards;sa=badges;u=1 I have selected in settings to show in posts, show total baged in posts and 10 number of badges all checked

Lastly, like a previous poster, I would like to manually award site sponsors with a larger badge (Perhaps 4 different ones)

Bronze Site Sponsor (For a yearly donation)
Silver Site Sponsor
Gold Site Sponsor
Platinum Site Sponsor

What can I do to get this done?

Thanks








Offline VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #1 on: July 25, 2015, 08:14:39 am »
I think I fixed the badges not displaying.  I copied code from the default theme in the display template into my theme.  The custom Badges where I could post the code for the badge next to the Avatar would be great.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Badges not displaying
« Reply #2 on: July 25, 2015, 08:22:48 am »
To create a custom badge that you manually award to someone you can do it the following way:
Admin -> Badge Awards -> Badge List
Then click "Add Badge"
Enter the badge information


Once the badge is made you can use
Admin -> Badge Awards -> Give Badge
To award a badge to a user



Quote
I have a general question first, is there a help file that shows all of the Action Labels or "Action" or are all of these hard coded already? 
Each badge must have their own unique action/id  the action itself doesn't mean anything but is used in the code to check to auto award the badge on certain condition.
You can make one  up for any of the new custom badges you create.

List of actions used already. Do not reuse these. It should not allow it anyway
action
"anniversary1"
"anniversary10"
"anniversary2"
"anniversary3"
"anniversary4"
"anniversary5"
"anniversary6"
"anniversary7"
"anniversary8"
"anniversary9"
"arcadechampion"
"arcadehighscore"
"arcademaster"
"avatar"
"badgeaction1"
"bigbadge"
"combination"
"gallery"
"group"
"invisible"
"karma"
"karmabad"
"karmagood"
"level1"
"level10"
"level11"
"level12"
"level13"
"level14"
"level15"
"level2"
"level3"
"level4"
"level5"
"level6"
"level7"
"level8"
"level9"
"mobile"
"neversleep"
"oldbrowser"
"osapple"
"oslinux"
"oswindows"
"photographer"
"poll"
"poll10"
"poll100"
"poll25"
"poll50"
"pollvote"
"pollvote10"
"pollvote100"
"pollvote50"
"posts1"
"posts10"
"posts100"
"posts1000"
"posts10000"
"posts100000"
"posts15000"
"posts20000"
"posts2500"
"posts50"
"posts500"
"posts5000"
"posts50000"
"quickposter"
"search"
"signature"
"spammer100"
"spammer25"
"spammer250"
"spammer50"
"spammer500"
"supercombination"
"topic"
"webmaster"
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 VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #3 on: July 25, 2015, 10:19:17 am »
Thanks, I will try that, but is there a way to have these 3-4 larger badges to be placed separately (Like under the Avatar) something that stands out.  I am just trying to find a way to distinguish members that are site sponsors.  I bought the Badge pack to do that, but I kinda like what it does to promote interaction of the forum so I am thinking of another way that I can label these people as sponsors in some way that is outside of membership groups because I want their number of posts to be shown too.

Thanks a LOT for the help on a SATURDAY!


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Badges not displaying
« Reply #4 on: July 25, 2015, 10:28:42 am »
This code function would do it. Do you want when viewing a post?



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

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

    if (empty($memberID))
        return; 
       
    if (empty($badgesList))
    {
    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 AND b.id_badge IN ($badgesList)
ORDER BY l.id_log DESC
LIMIT  $maxToShow
");
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$badgesCache[] = $row;

}

cache_put_data('badge_display_' . $memberID, $badgesCache, 60);

}

if (!empty($badgesCache))
foreach($badgesCache as $row)
{
echo '<img src="' . $modSettings['badgeawards_url']  . $row['image'] . '" alt="' . $row['title'] . '" title="' . $row['title'] . '" /> ';

}


}


Then example code
Code: [Select]
// The first column is the member id, second is order, third is number to show, the 4th column is what badge id's to only show
Badges_DisplayCustomBadges(###MEMBERIDHERE####, 'recent', 5, array(1,2,3,4,5));
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 VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #5 on: July 25, 2015, 10:51:47 am »
Yes on the posts, this is where other members would be seeing them most (maximum visibility) 

So where do I plug the function in? 

Offline VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #6 on: July 25, 2015, 12:29:41 pm »
Ok I created a custom badge called"Bronze Sponsor" with the Action Label:  bsponsor

I plugged the Function into the Badgeawards2.php 

And now I am trying to understand the function call Badges_DisplayCustomBadges.  I am not sure how to identify the 3 badege I want to make.

Either no sponsorship badge, Bronze Sponsor (bsponsor), Silver Sponsor (ssponsor), Gold Sponsor (gsponsor).

// The first column is the member id, second is order, third is number to show, the 4th column is what badge id's to only show
Badges_DisplayCustomBadges(###MEMBERIDHERE####, 'recent', 5, array(1,2,3,4,5));
Isn't the  ###MEMBERIDHERE#### supposed to be:  $message['member']['id']

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Badges not displaying
« Reply #7 on: July 25, 2015, 12:53:29 pm »
It should be  $message['member']['id'] if you are posting it in the displaly.template.php file in the message loop

The 1,2,3,4,5  are the badge id's. You need to change them to your custom badge ids
You can find the badge id by going to the badge list in the admin area.  Click on the edit badge link for the badge then in the address bar the url should have &id=  in it you want the number after the id
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 VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #8 on: July 25, 2015, 01:12:24 pm »
Here is what I plugged in  I only have one custom badge to test (I can add more but for this one to test I have the ID: 77  Forgive my php ignorance if this is wrong, I am just  looking at other code that looks the same.  But with the following I get a database..please try again error

   // The first column is the member id, second is order, third is number to show, the 4th column is what badge id's to only show      
      echo '<li class="blurb">' . Badges_DisplayCustomBadges($message['member']['id'], 'recent', 5, array(77)), '</li>';

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Badges not displaying
« Reply #9 on: July 25, 2015, 01:16:46 pm »
Made a mistake in the function updated function code
Code: [Select]
function Badges_DisplayCustomBadges($memberID = 0, $order = 'recent', $maxToShow = 5, $badgesList = array())
{
global $smcFunc, $modSettings, $boardurl;

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

    if (empty($memberID))
        return; 
       
    if (empty($badgesList))
    {
    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 AND b.id_badge IN (" . implode(",",$badgesList) . ")
ORDER BY l.id_log DESC
LIMIT  $maxToShow
");
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$badgesCache[] = $row;

}

cache_put_data('badge_display_' . $memberID, $badgesCache, 60);

}

if (!empty($badgesCache))
foreach($badgesCache as $row)
{
echo '<img src="' . $modSettings['badgeawards_url']  . $row['image'] . '" alt="' . $row['title'] . '" title="' . $row['title'] . '" /> ';

}


}
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 VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #10 on: July 25, 2015, 01:36:15 pm »
Well that took care of the error, but something is screwy.

This happened on two profiles.

The badges were working fine where I have the normal code (There are 5 or 6 badges for various things).

I added the custom badge to a profile and refreshed the post and the custom badge appeared where I want it in the new code, but then all the badges in the original code were gone except for the same custom badge. 

I Rem'ed out the new code and refreshed and the custom badge location goes away (as expected) however where the normal code is, the only badge that is there is the one custom one.  I refreshed the page several times and no change. 

So I tested the again with another profile and the same thing happens.

I have the regular badge code that  rather than show my 77 badge, it is showing all of them :/

Offline VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #11 on: July 25, 2015, 01:39:50 pm »
Ok I did another hard refresh and the original badges are back after rem'ing the new code out but still have the problems.

Also since I have you is there a way to use a larger Image for the badge in the new location (on the custom one)


Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15148
    • View Profile
Re: Badges not displaying
« Reply #12 on: July 25, 2015, 01:41:11 pm »
Well what this code does it allows you to just show the custom badges.

The original code shows all the badges that the user has been awarded so far.
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 VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #13 on: July 25, 2015, 01:44:59 pm »
Yeah I totally understand that.. and that's what I want, but it shouldn't affect the other code that displays all the badges..  When I add the new code leaving the existing code to show the other badges what I am wanting is a large Custom badge to show at the top and the other badges to show on the bottom. 

So to recap... the code works great, except that it is affecting the existing code when I have it activated on the same page.


Offline VapeTech

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Badges not displaying
« Reply #14 on: July 25, 2015, 01:52:58 pm »
Maybe this will help..  Here is a mock up of what I want and how it is working right now.

And again thank you so much for you help.

 

Related Topics

  Subject / Started by Replies Last post
16 Replies
9452 Views
Last post November 12, 2007, 09:02:29 pm
by Rafferty
4 Replies
2736 Views
Last post March 15, 2010, 08:38:12 am
by mandomercs
7 Replies
3069 Views
Last post August 31, 2014, 09:40:44 pm
by SMFHacks
1 Replies
1930 Views
Last post February 12, 2015, 09:55:14 pm
by SMFHacks
3 Replies
2124 Views
Last post July 06, 2017, 05:02:31 pm
by SMFHacks

+- Recent Topics

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

Deleting Empty Galleries by SMFHacks
August 30, 2020, 11:43:32 am

PHP error by davejo
August 25, 2020, 07:35:13 am

Permissions to list ads and buy items by CWVRV
August 21, 2020, 05:19:45 pm

Doubt with download permissions. by Rock Lee
August 20, 2020, 08:23:24 pm

Attachment images Upsidedown or Sideways by SMFHacks
August 18, 2020, 05:41:07 pm

[Mod]Avatars Display Integration by Hatshepsut
August 17, 2020, 11:39:54 pm

Simple Portal Block - Classifieds by SMFHacks
August 16, 2020, 09:56:48 am

SMF Links by SMFHacks
August 16, 2020, 08:03:42 am

Powered by EzPortal