SimplePortal
Customization => Custom Coding => Topic started by: dabeer on January 08, 2009, 07:32:11 AM
-
Hello everyone
First of all, thank a lot for that magnificent piece of software and the friendly support you´re providing here.
Now, my SMF 1.1.7 site has Thank-o-matic mod (1.2.5) installed and I´m wondering if it would be possible to create a ¨Most thanks received¨ block for the Portal (2.0.5), which would display who received the most thanks in Thank-o-matic, in a similar fashion to "Top 5 posters" block.
Any hints on how to achieve this?
Cheers.
-
i think i can make a php block for this ;)
-
I'd be very much obliged :holding-flower:
-
The easiest way is :)
Most Thank Yo Given:
global $boarddir;
require_once($boarddir.'/SSI.php');
ssi_thankYouPostTopGiven(5);
Most Thanks You's resived:
global $boarddir;
require_once($boarddir.'/SSI.php');
ssi_thankYouPostTopResived(5);
You can change the 5 to the number you like to see :).
Bye
DIN1031
-
Thank you, it worked, however I had to change line 2 of the code to:
require_once($boarddir.'/SSI.php');
(slash was missing)
Also, shouldn't the name of the function be ssi_thankYouPostTopReceived instead of ssi_thankYouPostTopResived?
Anyone got an idea how to display avatars there as well?
-
Yes that was a mistake in my first version... but i could not change it because so many use it when i saw it xD.
Hmmm avatars is not so easy, but i will see if i can do that :X.
Bye
DIN1031
-
Hmmm avatars is not so easy, but i will see if i can do that :X.
Actually, I'm really glad to have got it working the way it does now, but if you ever come up with code that shows avatars as well, I'll be delighted.
-
While we're at Thank-o-matic code, another thing worth considering would be a kind of "top 5 thanks received posts" which would display X posts with most thanks received (so the most valuable ones, the mod could actually be called "5 Most Valuable posts")
What do you reckon?
Any easy way of implementing that?
-
It's not so easy, because it's the standard ssi version :X
-
TopGiven with avatars:
global $boarddir, $memberContext;
require_once($boarddir.'/SSI.php');
$top_given = ssi_thankYouPostTopGiven(5, 'array');
echo '
<table>';
foreach ($top_given as $member)
{
loadMemberData($member['id']);
loadMemberContext($member['id']);
echo '
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$member['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$member['id']]['avatar']['href'] . '" alt="' . $member['name'] . '" width="50" />' : '', '
</td>
<td>
', $member['link'], '<br />
<span class="smalltext">
<strong>', $txt['thank_you_post_made_display'], ':</strong> ', $member['thank_you_post_made'], '<br />
<strong>', $txt['thank_you_post_became_display'], ':</strong> ', $member['thank_you_post_became'], '
</span>
</td>
</tr>';
}
echo '
</table>';
If you want it to be top recieved, just change 'TopGiven' to 'TopResived'.
Top Thanked Posts:
global $db_prefix, $scripturl, $user_info, $txt;
$request = db_query("
SELECT
m.ID_MSG, m.ID_TOPIC, m.ID_MEMBER, m.subject, COUNT(*) AS thanks,
IFNULL(mem.realName, m.posterName) AS posterName
FROM {$db_prefix}thank_you_post AS ty
LEFT JOIN {$db_prefix}messages AS m ON (m.ID_MSG = ty.ID_MSG)
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = m.ID_BOARD)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE $user_info[query_see_board]
AND b.thank_you_post_enable = 0
GROUP BY ID_MSG
ORDER BY thanks DESC
LIMIT 10", __FILE__, __LINE__);
$return = array();
while ($row = mysql_fetch_assoc($request))
$return[] = array(
'id' => $row['ID_MSG'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
'thanks' => $row['thanks'],
);
mysql_free_result($request);
echo '
<ol>';
foreach ($return as $post)
echo '
<li>', $post['link'], ' <span class="smalltext">', $txt[525], ' ', $post['poster']['link'], '<br />', $txt['thank_you_post_thx_display'], ': ', $post['thanks'], '</li>';
echo '
</ol>';
-
Thanks, Blue Dream! Exactly what I had in mind ;D
In Top Thanks Given/Received the only problem is that the strings $txt['thank_you_post_made_display'] and $txt['thank_you_post_become_display'] are not displayed. Both strings are defined in index.MYLANGUAGE.php and they are both displayed without problems in other mods. Any idea what I'm missing?
-
Find:
global $boarddir, $memberContext;
Repace:
global $boarddir, $memberContext, $txt;
-
Thanks, it worked!