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

computel

I put the code posted in my display.php & my Display.template.php and I don't see the rewards listed under the avatar. Am I missing something?

eNoyx

#321
I can't get it to work either... followed the directions carefully, but no awards below the avatar ^^' Please, some help here, this mod is great and with that "hack" it'll be perfect!

Cya!

[edit] Finally I got it work ^^ I don't remember exactly what I did but... I think that is related to custom themes... If you have a custom theme in use, you have to apply the "hack" to both default and your custom theme. At least that is what I think that has done.

Another thing... I want the award image to have a title that displays the title of the award. Currently I've set the code like this:
Code (display.php) Select

/ Load the members awards
$awards_request = db_query("
SELECT pab.filename, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")", __FILE__, __LINE__);

$context['awards'] = array();
$context['awards'][$row['ID_MEMBER']] = array();
while ($row = mysql_fetch_assoc($awards_request))
$context['awards'][$row['ID_MEMBER']][] = '<img src="' . dirname($scripturl) . '/' . (empty($modSettings['pa_awardsDir']) ? '' : $modSettings['pa_awardsDir'] . '/') . $row['filename'] . '" alt="' . $row['filename'] . '" title="' . $row['filename'] . '" />';

mysql_free_result($awards_request);


Just added title="' . $row['filename'] . '" to the end of the <img /> line. But that only displays the filename as the title. Is it possible to display the title of the Award? I mean, what $row do I have to use?

- [edit2] -
I figured out how to do it ^^ This is the final code:

Code (display.php) Select

/ Load the members awards
$awards_request = db_query("
SELECT pab.filename, pab.awardName, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")", __FILE__, __LINE__);

$context['awards'] = array();
$context['awards'][$row['ID_MEMBER']] = array();
while ($row = mysql_fetch_assoc($awards_request))
$context['awards'][$row['ID_MEMBER']][] = '<img src="' . dirname($scripturl) . '/' . (empty($modSettings['pa_awardsDir']) ? '' : $modSettings['pa_awardsDir'] . '/') . $row['filename'] . '" alt="' . $row['filename'] . '" title="' . $row['awardName'] . '" />';

mysql_free_result($awards_request);


I just changed the SELECT query (adding pab.awardName) and the $row to use with the title is '" title="' . $row['awardName'] . '"
Don't know really if this is optimized and those things... I have almost no idea about PHP/MySQL, just looked the code and thought how it'd be using the logic and common sense ;) So, if it's any modification that it should be done, please tell me ^^

Cya!

sportographer

Quote from: TechnoDragon on January 20, 2007, 11:07:49 AM
The problem was in the original code i posted I used a $txt string (modified the language template) so it was translation compatible...that is why it wasn't showing up at first...

is there any chance for the award .gif/.jpg to appear under the post? i get "number of award - 1"

perplexed

Is it possible to create an award for people who post a certain number of times on a particular board in a forum?

Like a reward for posting where we want them to post ie on topic areas as opposed to just overall # of posts.


JayBachatero

Stigmartyr and computel: You still haven't gotten the awards to show?

Quote from: sportographer on January 23, 2007, 07:14:48 AM
Quote from: TechnoDragon on January 20, 2007, 11:07:49 AM
The problem was in the original code i posted I used a $txt string (modified the language template) so it was translation compatible...that is why it wasn't showing up at first...

is there any chance for the award .gif/.jpg to appear under the post? i get "number of award - 1"
I believe I posted this in the first few pages.  Look at the first few pages.

Quote from: perplexed on January 23, 2007, 03:57:04 PM
Is it possible to create an award for people who post a certain number of times on a particular board in a forum?

Like a reward for posting where we want them to post ie on topic areas as opposed to just overall # of posts.
No, it's not possible to do this.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert


computel

I still can't get it to show as a I made the changes to the two files but I don't see the reward under the avatar.

Thanks


Quote from: JayBachatero on January 23, 2007, 05:08:30 PM
Stigmartyr and computel: You still haven't gotten the awards to show?



JayBachatero

Are you using a custom theme?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert


JayBachatero

Can you post your Display.php and Display.template.php files?
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

computel

also attached both files

Display.php
  // Load the members awards
$awards_request = db_query("
SELECT pab.filename, pam.ID_MEMBER
FROM {$db_prefix}awards_members AS pam
LEFT JOIN {$db_prefix}awards AS pab ON (pab.ID_AWARD = pam.ID_AWARD)
WHERE pam.ID_MEMBER IN (" . implode(', ', $posters) . ")
AND pam.favorite = 1
GROUP BY pam.ID_MEMBER", __FILE__, __LINE__);

$context['awards'] = array();
while ($row = mysql_fetch_assoc($awards_request))
$context['awards'][$row['ID_MEMBER']] = '<img src="' . dirname($scripturl) . '/' . (empty($modSettings['pa_awardsDir']) ? '' : $modSettings['pa_awardsDir'] . '/') . $row['filename'] . '" alt="' . $row['filename'] . '" />';

mysql_free_result($awards_request);
       // end of awards mod


Display.template.php
// Show the fav award
if (isset($context['awards'][$message['member']['id']]))
echo '
<div style="overflow: auto; width: 100%;">';
// end of show the fav award mod

JayBachatero

That explains that.  You have an opening div tag but nothing else.  Seems like a copy paste issue.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert


JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

sportographer

hey jay, just need a little help with the link you gave me (http://www.simplemachines.org/community/index.php?topic=114701.msg749906#msg749906.)

where is display.php located? i've added in the display.template.php code in but can't find display.php using black22TP theme

sportographer

ah got it to work, you lil beauty jay! awesome mod!!

sportographer

any chance of having ALL awards displayed underneath? not just the fav

computel

OK got it working but it doesn't say the award what it is. how do I get this to show?

Thanks

JayBachatero

sportographer I posted how to do this a few pages back.  Can't link you since I'm on my cell.

computel someone posted hw to do this a few pages back.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

sportographer

thanks jay, i couldn't find it but ill keep seraching/wait til you get back

keep up the AMAZING work

Advertisement: