SMFHacks.com
Badge Awards => Support => Topic started by: Dylert on September 03, 2012, 04:55:59 pm
-
Hi! I'm using TinyPortal and would love to have a side block where the latest badges given are listed. Just like the list in the info center. Is that hard to make?
-
Some example code
//Start Badge Awards
global $modSettings, $boardurl, $smcFunc;
if ($modSettings['badgeawards_showboardindex'] == true && !empty($modSettings['badgeawards_enable']))
{
if (empty($modSettings['badgeawards_boardnumdisplay']))
$modSettings['badgeawards_boardnumdisplay'] = 10;
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
$dbresult = $smcFunc['db_query']('', "SELECT
b.id_badge, b.title, b.image, b.enabled,
l.ID_MEMBER, l.date, l.id_log, m.real_name
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
LEFT JOIN {db_prefix}members as m ON (m.ID_MEMBER = l.ID_MEMBER)
WHERE l.id_badge = b.id_badge
ORDER BY l.id_log DESC
LIMIT " . $modSettings['badgeawards_boardnumdisplay']);
$context['badge_recentindex'] = array();
while($row = mysql_fetch_assoc($dbresult))
{
$context['badge_recentindex'][] = $row;
}
mysql_free_result($dbresult);
}
foreach ($context['badge_recentindex'] as $pic)
{
echo '<a href="' . $scripturl . '?action=badgeawards;sa=badges;u=' . $pic['ID_MEMBER'] . '">' . $pic['title'] . '</a> ' . $txt['badges_to'], ' ', ($pic['real_name'] != '' ? '<a href="' . $scripturl . '?action=profile;u=' . $pic['ID_MEMBER'] . '">' . $pic['real_name'] . '</a>' : '') . '
', timeformat($pic['date']), '<br />';
}
//END Badge Awards
-
Just what i need! Thanks a lot! :)
-
Is it possible, to show the Badge next (in front of) to the username inside this block-code?
-
You mean the badge icon/image itself?
-
Mhhh....regulary this is what i want:
(SMF 2.0.4 with SimplePortal 2.3.5)
A streaming Badge List inside a block.
-
Bumb....
-
A streaming block would take me a while to do but I could do recent badges in a block in a couple posts up is the recent badges code for SMF 2.0.x
-
Some example code
//Start Badge Awards
global $modSettings, $boardurl, $smcFunc;
if ($modSettings['badgeawards_showboardindex'] == true && !empty($modSettings['badgeawards_enable']))
{
if (empty($modSettings['badgeawards_boardnumdisplay']))
$modSettings['badgeawards_boardnumdisplay'] = 10;
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
$dbresult = $smcFunc['db_query']('', "SELECT
b.id_badge, b.title, b.image, b.enabled,
l.ID_MEMBER, l.date, l.id_log, m.real_name
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
LEFT JOIN {db_prefix}members as m ON (m.ID_MEMBER = l.ID_MEMBER)
WHERE l.id_badge = b.id_badge
ORDER BY l.id_log DESC
LIMIT " . $modSettings['badgeawards_boardnumdisplay']);
$context['badge_recentindex'] = array();
while($row = mysql_fetch_assoc($dbresult))
{
$context['badge_recentindex'][] = $row;
}
mysql_free_result($dbresult);
}
foreach ($context['badge_recentindex'] as $pic)
{
echo '<a href="' . $scripturl . '?action=badgeawards;sa=badges;u=' . $pic['ID_MEMBER'] . '">' . $pic['title'] . '</a> ' . $txt['badges_to'], ' ', ($pic['real_name'] != '' ? '<a href="' . $scripturl . '?action=profile;u=' . $pic['ID_MEMBER'] . '">' . $pic['real_name'] . '</a>' : '') . '
', timeformat($pic['date']), '<br />';
}
//END Badge Awards
This is not working for me. Anything that needs to be updated?
-
Where are you putting that code?
It is checking to see if the boardindex is enabled to display the badges you can take out that check and see if it runs
-
Where are you putting that code?
It is checking to see if the boardindex is enabled to display the badges you can take out that check and see if it runs
Sorry, it's a simpleportal block.
I removed the boardindex if... still nothing
//Start Badge Awards
global $modSettings, $boardurl, $smcFunc;
if (!empty($modSettings['badgeawards_enable']))
{
if (empty($modSettings['badgeawards_boardnumdisplay']))
$modSettings['badgeawards_boardnumdisplay'] = 10;
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
$dbresult = $smcFunc['db_query']('', "SELECT
b.id_badge, b.title, b.image, b.enabled,
l.ID_MEMBER, l.date, l.id_log, m.real_name
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
LEFT JOIN {db_prefix}members as m ON (m.ID_MEMBER = l.ID_MEMBER)
WHERE l.id_badge = b.id_badge
ORDER BY l.id_log DESC
LIMIT " . $modSettings['badgeawards_boardnumdisplay']);
$context['badge_recentindex'] = array();
while($row = mysql_fetch_assoc($dbresult))
{
$context['badge_recentindex'][] = $row;
}
mysql_free_result($dbresult);
}
foreach ($context['badge_recentindex'] as $pic)
{
echo '<a href="' . $scripturl . '?action=badgeawards;sa=badges;u=' . $pic['ID_MEMBER'] . '">' . $pic['title'] . '</a> ' . $txt['badges_to'], ' ', ($pic['real_name'] != '' ? '<a href="' . $scripturl . '?action=profile;u=' . $pic['ID_MEMBER'] . '">' . $pic['real_name'] . '</a>' : '') . '
', timeformat($pic['date']), '<br />';
}
//END Badge Awards
-
Updated code
<?php
require 'SSI.php';
//Start Badge Awards
global $modSettings, $boardurl, $smcFunc;
if (!empty($modSettings['badgeawards_enable']))
{
if (empty($modSettings['badgeawards_boardnumdisplay']))
$modSettings['badgeawards_boardnumdisplay'] = 10;
if (empty($modSettings['badgeawards_url']))
$modSettings['badgeawards_url'] = $boardurl . '/badges/';
$dbresult = $smcFunc['db_query']('', "SELECT
b.id_badge, b.title, b.image, b.enabled,
l.ID_MEMBER, l.date, l.id_log, m.real_name
FROM ({db_prefix}badgeawards_badges as b, {db_prefix}badgeawards_badge_log as l)
LEFT JOIN {db_prefix}members as m ON (m.ID_MEMBER = l.ID_MEMBER)
WHERE l.id_badge = b.id_badge
ORDER BY l.id_log DESC
LIMIT " . $modSettings['badgeawards_boardnumdisplay']);
$context['badge_recentindex'] = array();
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
$context['badge_recentindex'][] = $row;
}
}
foreach ($context['badge_recentindex'] as $pic)
{
echo '<a href="' . $scripturl . '?action=badgeawards;sa=badges;u=' . $pic['ID_MEMBER'] . '">' . $pic['title'] . '</a> ' . $txt['badges_to'], ' ', ($pic['real_name'] != '' ? '<a href="' . $scripturl . '?action=profile;u=' . $pic['ID_MEMBER'] . '">' . $pic['real_name'] . '</a>' : '') . '
', timeformat($pic['date']), '<br />';
}
//END Badge Awards
-
Updated code
It's missing the images
-
Images were not part of that code originally.