News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Member Awards (2.0 Compatible!)

Started by Spuds, September 18, 2006, 03:14:03 PM

Previous topic - Next topic

Kimmie

Quote from: ljprevo on August 24, 2008, 01:50:12 AM
This may have been asked, I couldn't find anything on this, but is there a way to get the badges to show up under the member's avatar in post?

I just want the badges to show, and a hover of the badge name, and the link to everyone who has that badge.

This would be a good idea. maybe add an icon underneath each image like the "favorite" image. Only thing is tho.. would that work on forums like mine where I dont allow regular members to upload their avatars to the server - they have to be uploaded elsewhere.

Fustrate

Steven Hoffman
Former Team Member, 2009-2012


Fustrate

I don't yet have full control of this mod, JayBachatero says it's probably going to get switched over this week. Once it is, I'll release a new version for the 1.1.x line that includes that code, and the 2.0 version which already has that and much more.
Steven Hoffman
Former Team Member, 2009-2012

Kimmie

Quote from: YodaOfDarkness on August 24, 2008, 05:35:19 PM
I don't yet have full control of this mod, JayBachatero says it's probably going to get switched over this week. Once it is, I'll release a new version for the 1.1.x line that includes that code, and the 2.0 version which already has that and much more.


so what your saying is.. unless we are on 2.0 were not gonna get all those extra features? hehehe

I'm glad to see that you are taking this mod over period. So many mods have been "thrown to the wolves" since 2.0 came out which is really not fair to those of us who for whatever reason have chosen not to upgrade to 2.0. :).

Will your new version be equipped with an "upgrade" or will we have to uninstall the one we currently use and install the new one? Reason I ask is I dont want to have to lose all that data from an uninstall. I worked too hard and have given too many awards to go through all that..lol. If I can know ahead of time that its not going to be an upgrade, I can go ahead and make the necessary edits on the one I have now using the code from the post you listed above.

Fustrate

It'll use slightly different code that makes far less database queries, but I'll post that as an easy upgrade to the new version that you can do by hand. But yes, the new features will be 2.0-only. I'll only be doing bug fixes and that one feature addition for 1.1.x.
Steven Hoffman
Former Team Member, 2009-2012

Kimmie

#746
Quote from: YodaOfDarkness on August 25, 2008, 01:07:07 AM
It'll use slightly different code that makes far less database queries, but I'll post that as an easy upgrade to the new version that you can do by hand. But yes, the new features will be 2.0-only. I'll only be doing bug fixes and that one feature addition for 1.1.x.

I went ahead and did the code edits and I keep getting this error

Undefined index: pa_favorite
File: /home//public_html/Themes/default/languages/Profile.english.php (main sub template - eval?)
Line: 46

any idea why?

this is line 46:
$txt[598] = 'This must be included if you specify a URL below.';

Fustrate

It's definitely not an error in Profile.english.php, I know that much.

Add this line to the end of Modifications.english.php:
$txt['pa_favorite'] = 'Favorite Award';
Steven Hoffman
Former Team Member, 2009-2012

Kimmie

#748
Quote from: YodaOfDarkness on August 25, 2008, 02:08:40 AM
It's definitely not an error in Profile.english.php, I know that much.

Add this line to the end of Modifications.english.php:
$txt['pa_favorite'] = 'Favorite Award';


Looks like that got it :). Thanks!!! :)

Edit: 1 quick question - I figured out how to change it from showing 4 to just showing 1, but isnt this also supposed to show on posts the # of awards as well? Mine doesnt :(

Fustrate

No, it doesn't show the number of awards.
Steven Hoffman
Former Team Member, 2009-2012

Kimmie

Quote from: YodaOfDarkness on August 26, 2008, 01:24:35 AM
No, it doesn't show the number of awards.

ah ok.. i was assuming it did because of how you started out that post:

QuoteEDIT: I just figured it out  Here's how to display (#) awards under a person's avatar.

Its no biggie. Having it just show the award is fine with me. :)

Marcus Forsberg

Will this work whit 2.x?

And if not, will it do in the future?

Fustrate

I have upgraded it for 2.0, but I can't quite release it until I get control of this mod. If you want to use the 2.0 version, just send me a PM and I'll send you back a link to the file.
Steven Hoffman
Former Team Member, 2009-2012

callteg4

Quote from: YodaOfDarkness on July 06, 2007, 09:11:42 PM
From my earlier post - changed $maxAwards to 1 to just show the favorite (it'll show a random badge if they don't set a favorite)

Quote from: YodaOfDarkness on June 29, 2007, 11:25:59 PM
EDIT: I just figured it out :) Here's how to display (#) awards under a person's avatar. It's a modification of code found in... whichever file has the awards() function :D

All in Display.template.php (it all works the same anyways...)
find:
function template_main()
and add before (this is right at the top):
function show_awards_in_message($memID)
{
global $context, $db_prefix, $txt, $scripturl, $modSettings, $settings;

// How many awards to pull up? 1 for Favorite
$maxAwards = 1;

// Count the number of items in the database for create index
$request = db_query("
SELECT COUNT(*)
FROM {$db_prefix}awards_members
WHERE ID_MEMBER = $memID", __FILE__, __LINE__);
list ($countAM) = mysql_fetch_row($request);
mysql_free_result($request);

// The count of awards per member
$context['countAwards'] = $countAM;

// Load the awards
$awardsSelect = db_query("
SELECT
aw.ID_AWARD, aw.awardName, aw.gameName, aw.filename, aw.width, aw.height,
am.ID_MEMBER, am.dateReceived, am.favorite
FROM {$db_prefix}awards AS aw
LEFT JOIN {$db_prefix}awards_members AS am ON (am.ID_AWARD = aw.ID_AWARD)
WHERE am.ID_MEMBER = $memID
ORDER BY am.favorite DESC, am.dateReceived DESC
LIMIT 0, $maxAwards", __FILE__, __LINE__);

// Set the $context['awards'] var
$context['awards'] = array();

// Fetch the award info just once
while ($row = mysql_fetch_assoc($awardsSelect))
{
$context['awards'][$row['ID_AWARD']] = array(
'id' => $row['ID_AWARD'],
'awardName' => $row['awardName'],
'gameName' => $row['gameName'],
'more' => $scripturl . '?action=profile;sa=awardsMembers;id=' . $row['ID_AWARD'],
'favorite' => array(
'fav' => $row['favorite'],
'href' => $scripturl . '?action=profile;sa=awards;id=' . $row['ID_AWARD'] . ';makeFavorite=' . ($row['favorite'] == 1 ? '0' : '1') . (isset($_REQUEST['u']) ? ';u=' . $_REQUEST['u'] : ''),
'img' => '<img src="' . $settings['images_url'] . '/' . ($row['favorite'] == 1 ? 'collapse' : 'expand') . '.gif" alt="' . $txt['pa_favorite'] . '" />',
),
'filename' => $row['filename'],
'width' => $row['width'],
'height' => $row['height'],
'time' => list ($year, $month, $day) = sscanf($row['dateReceived'], '%d-%d-%d'),
'img' => dirname($scripturl) . '/' . $modSettings['pa_awardsDir'] . '/' . $row['filename'],
);
}
mysql_free_result($awardsSelect);

if (!empty($context['awards'])){
foreach ($context['awards'] as $award){
echo '<a href="', $award['more'], '"><img src="', $award['img'], '" width="', $award['width'], '" height="', $award['height'], '" alt="', $award['awardName'], '" title="', $award['awardName'], '" /></a> ';
}
echo '<br />
<br />';
}
}


then go down a bit farther, find:
// Show their personal text?
if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
echo '
', $message['member']['blurb'], '<br />
<br />';

add after:
show_awards_in_message($message['member']['id']);

You can actually put the second part wherever you like, but I personally like how the personal text seperates the avatar from the awards. It's also possible to make them stand out using a fieldset and a legend, which is what I did with mine.

This is why I love SMF... I get to learn while I tinker with things :D

EDIT: Fixed the error I was having with second/third/etc. pages - it was using $context['start'] when it should have used 0, and I condensed the code :)

Thanks alot been trying to do this for a while

Deadfire

I really like this mod however if it's possible I would like to do a few things for my clan site using this mod. (I assume this will work on 1.1.5)

Can I have the awards page of the profile be not a separate page, but instead under the summary of a person's profile. As well If possible can I have the Award images show up in the signature of the member that has them. Much like a medal rack would look like. Lastly, if possible have two images per award, one that appears in the profile, the other that appears in the signature.

The reason for these edits to introduce medals and ribbons to my Clan's site. A person looking at the member's profile sees a military record of sorts, with medals in full shown in it. As well with the member posting a person can see the medal rack in that persons signature (or a separate box altogether above the signature) that shows just the ribbon and not the full award that appears in the member's profile.

If you can help me out that would be great, however if it looks like those edits require custom work. I'm not afraid of footing the bill for it.

Thanks,

Deadfire
www.jsoc-unit.com

Fustrate

Quote from: Deadfire on August 31, 2008, 06:49:34 PM
I really like this mod however if it's possible I would like to do a few things for my clan site using this mod. (I assume this will work on 1.1.5)

Can I have the awards page of the profile be not a separate page, but instead under the summary of a person's profile. As well If possible can I have the Award images show up in the signature of the member that has them. Much like a medal rack would look like. Lastly, if possible have two images per award, one that appears in the profile, the other that appears in the signature.

The reason for these edits to introduce medals and ribbons to my Clan's site. A person looking at the member's profile sees a military record of sorts, with medals in full shown in it. As well with the member posting a person can see the medal rack in that persons signature (or a separate box altogether above the signature) that shows just the ribbon and not the full award that appears in the member's profile.

If you can help me out that would be great, however if it looks like those edits require custom work. I'm not afraid of footing the bill for it.

Thanks,

Deadfire
www.jsoc-unit.com
For showing them in the post, look in the post right above yours ;) they quoted my solution in whole.

As for showing them on the main profile page, I guess it's possible... I'd have to look into the code, but it wouldn't be much of a problem.
Steven Hoffman
Former Team Member, 2009-2012

Deadfire

#756
Quote from: YodaOfDarkness on August 31, 2008, 06:59:51 PM
Quote from: Deadfire on August 31, 2008, 06:49:34 PM
I really like this mod however if it's possible I would like to do a few things for my clan site using this mod. (I assume this will work on 1.1.5)

Can I have the awards page of the profile be not a separate page, but instead under the summary of a person's profile. As well If possible can I have the Award images show up in the signature of the member that has them. Much like a medal rack would look like. Lastly, if possible have two images per award, one that appears in the profile, the other that appears in the signature.

The reason for these edits to introduce medals and ribbons to my Clan's site. A person looking at the member's profile sees a military record of sorts, with medals in full shown in it. As well with the member posting a person can see the medal rack in that persons signature (or a separate box altogether above the signature) that shows just the ribbon and not the full award that appears in the member's profile.

If you can help me out that would be great, however if it looks like those edits require custom work. I'm not afraid of footing the bill for it.

Thanks,

Deadfire
www.jsoc-unit.com
For showing them in the post, look in the post right above yours ;) they quoted my solution in whole.

As for showing them on the main profile page, I guess it's possible... I'd have to look into the code, but it wouldn't be much of a problem.

Heh I did see that, making a box above the signature box shouldn't be much of a issue just using that code, however the difference is with having 2 images for the same award, one being shown in the profile, the other being shown in the signature.

you can chat with me on AIM if you like on this, my AIM is promdeadfire

Fustrate

Do you mean having a smaller image in there for the one above the signature? If so, put another folder inside your /awards/ directory called 'small' and find this line of code:
         'img' => dirname($scripturl) . '/' . $modSettings['pa_awardsDir'] . '/' . $row['filename'],

and replace it with
         'img' => dirname($scripturl) . '/' . $modSettings['pa_awardsDir'] . '/small/' . $row['filename'],

and remove the height and width attributes from the <img> tag
Steven Hoffman
Former Team Member, 2009-2012

Fievel Lee


how can i use this mod on a 1.1.4 forum with spanish latin language ?  :-\



Advertisement: