SimplePortal
Customization => Blocks and Modifications => Topic started by: Blue on April 29, 2009, 09:49:13 PM
-
[FOR SMF 2.0 ONLY]
Hi :)
I wanted a mod that could join all the TOP I used: Top Posts, Top Karmas and Top Money (SMF Shop)
So, I decided to do one. Here it is:
Updated: HTML Validity - Thanks to [SiNaN]
Without TOP Money (Use this if you don't have SMF Shop)
//TOP POSTS
//TOP POSTS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img527.imageshack.us/img527/3337/86263199.gif" alt="posts" />
<strong>Top Posts</strong>
</div>
<hr />';
// TOP POSTS [CODE]
global $boarddir, $memberContext;
require_once($boarddir.'/SSI.php');
$top_given = ssi_topPoster(3, '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="30" height="27" />' : '', '
</td>
<td>
', $member['link'], '<br />
<span class="smalltext">
<strong>Posts:</strong> ', $member['posts'], '
</span>
</td>
</tr>';
}
echo '
</table>';
echo'
<br />';
//TOP KARMAS
//TOP KARMAS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img2.imageshack.us/img2/419/85312373.gif" alt="karma" />
<strong>Top Karmas</strong>
</div>
<hr />';
// TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, karma_good
FROM {db_prefix}members
ORDER BY karma_good DESC
LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$members[] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'karma' => $row_members['karma_good'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);
}
$smcFunc['db_free_result']($members_result);
if (empty($members))
return;
echo '<table>';
foreach ($members as $karma) {
echo '
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
</td>
<td>
', $karma['link'], '<br />
<span class="smalltext">
<strong>Karmas:</strong> ', $karma['karma'], '
</span>
</td>
</tr>';
}
echo '
</table>';
With TOP Money (only if you have SMF Shop)
//TOP POSTS
//TOP POSTS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img527.imageshack.us/img527/3337/86263199.gif" alt="posts" />
<strong>Top Posts</strong>
</div>
<hr />';
// TOP POSTS [CODE]
global $boarddir, $memberContext;
require_once($boarddir.'/SSI.php');
$top_given = ssi_topPoster(3, '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="30" height="27" />' : '', '
</td>
<td>
', $member['link'], '<br />
<span class="smalltext">
<strong>Posts:</strong> ', $member['posts'], '
</span>
</td>
</tr>';
}
echo '
</table>';
echo'
<br />';
//TOP KARMAS
//TOP KARMAS [TITLE]
echo'
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img2.imageshack.us/img2/419/85312373.gif" alt="karma" />
<strong>Top Karmas</strong>
</div>
<hr />';
// TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, karma_good
FROM {db_prefix}members
ORDER BY karma_good DESC
LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$members[] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'karma' => $row_members['karma_good'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);
}
$smcFunc['db_free_result']($members_result);
if (empty($members))
return;
echo '<table>';
foreach ($members as $karma) {
echo '
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
</td>
<td>
', $karma['link'], '<br />
<span class="smalltext">
<strong>Karmas:</strong> ', $karma['karma'], '
</span>
</td>
</tr>';
}
echo '
</table>';
// TOP MONEY [CODE]
global $smcFunc, $scripturl, $memberContext;
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, money
FROM {db_prefix}members
ORDER BY money DESC
LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$members[] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'money' => $row_members['money'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);
}
$smcFunc['db_free_result']($members_result);
if (empty($members))
return;
echo '<table>';
foreach ($members as $money) {
echo '
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$money['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$money['id']]['avatar']['href'] . '" alt="' . $money['name'] . '" width="30" height="27" />' : '', '
</td>
<td>
', $money['link'], '<br />
<span class="smalltext">
<strong>Money:</strong> ', $money['money'], '
</span>
</td>
</tr>';
}
echo '
</table>';
ScreenShot Attached. Hope you like it ;)
-
Looks good. Moved to the Blocks and Modifications board. :)
-
Thanks ;D
-
Thank you, awesome job did you get smf shop on 2.0 rc1
-
Good job Blue! Looks great.
Here are some suggestions to make it perfect.
For this code:
<center><img src="http://img259.imageshack.us/img259/7306/yen.png" align="abscenter" > <span class="smalltext"><font color="#216095"><b>Top Money</b></font></span></center>
I'd have used this:
<div class="smalltext" style="text-align: center; color: #216095;">
<img src="http://img259.imageshack.us/img259/7306/yen.png" alt="money" />
<strong>Top Money</strong>
</div>
So you put everything in a div which has smalltext class assigned and text inside is aligned to center by text-align: center; and text color is set with color: #216095;.
With this, you can get rid of deprecated tags (center and font) and an extra span tag. In addition, you won't need to use align attribute for img tag, which is also decprecated, as text-align: center; for the div would align it to center too. Also, instead of deprecated tag, b, you can use strong. Lastly, img tag requires alt attribute to be HTML valid.
Also, instead of <hr> use <hr /> and for <br/ > or <br> use <br />, again for HTML validity.
-
:0 Didn't knew about HTML validity
I'm going to change that, then :) -----> Done ;)
Thanks for the "teaching lessons" ;D I'm learning, I'm learning :D
The <div> thing is cool. At least the code becomes more eye looking :P
-
Looks great, well done! You're learning fast. :D
-
I'm a quick learner, I told you on the other topic eheh :P
Any problem if my next block be a "Shoutbox Smart Block" (with detection of the shoutbox installed?) :-[
-
Of course not, you can code whatever you like. ;)
Also, while creating "smart blocks" you can cheat from built-in "intelligent blocks" of SimplePortal. ;P
-
Also, while creating "smart blocks" you can cheat from built-in "intelligent blocks" of SimplePortal. ;P
I know, I know, I was already doing that eheh :P
-
why it isnt worked at mine site are we include the codes in php area
-
Hello MUSTAFAINE,
It isn't working because you are using SMF 1.1.8 and this is ONLY for SMF 2.0 ;)
-
you right blue, i just want to ask the all mods for 2.0 or not.
i couldn`t see any comment but i am new here I ll learn the site thanks..
-
The blocks made by me are for SMF 2.0
I've updated them with a warning telling it's only for SMF 2 ;)
-
Blue can you code one for 1.1.9 please ^^
-
If I wanted to exclude certain groups, how would I code that in?
Thank you,
Prime
-
It would require some
Blue can you code one for 1.1.9 please ^^
Sorry, it's only available for SMF 2.0
If I wanted to exclude certain groups, how would I code that in?
Thank you,
Prime
The only solution I know is that would require to call the table of the members of the database and then put the code in an IF.
-
Any way to make it show the user colors?
Like the Admin: Red
Mods: Green
-
Can anyone add the code for Top Arcade Players as well?
-
Can someone please help me adapt the highest karma code to 1.1.12?
// TOP KARMAS [CODE]
global $smcFunc, $scripturl, $memberContext;
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, karma_good
FROM {db_prefix}members
ORDER BY karma_good DESC
LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$members[] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'karma' => $row_members['karma_good'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);
}
$smcFunc['db_free_result']($members_result);
if (empty($members))
return;
foreach ($members as $karma)
echo '
<table>
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
</td>
<td>
', $karma['link'], '<br />
<span class="smalltext">
<strong>Karmas:</strong> ', $karma['karma'], '
</span>
</td>
</tr>';
echo '
</table>';
I wanted to adapt it into the SSI.php file and give it a ssi_NAME. Here's what I did:
// TOP KARMAS [CODE]
function ssi_topKARMA($topNumber = 1, $num_posts, $output_method
= 'echo')
{
global $smcFunc, $scripturl, $memberContext;
$members_result = $smcFunc['db_query']('', '
SELECT id_member, real_name, karma_good
FROM {db_prefix}members
ORDER BY karma_good DESC
LIMIT 3');
$members = array();
while ($row_members = $smcFunc['db_fetch_assoc']($members_result))
{
$members[] = array(
'name' => $row_members['real_name'],
'id' => $row_members['id_member'],
'karma' => $row_members['karma_good'],
'href' => $scripturl . '?action=profile;u=' . $row_members['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['id_member'] . '">' . $row_members['real_name'] . '</a>'
);
}
$smcFunc['db_free_result']($members_result);
if (empty($members))
return;
foreach ($members as $karma)
echo '
<table>
<tr>
<td style="width: 55px; text-align: center;">', !empty($memberContext[$karma['id']]['avatar']['href']) ? '
<img src="' . $memberContext[$karma['id']]['avatar']['href'] . '" alt="' . $karma['name'] . '" width="30" height="27" />' : '', '
</td>
<td>
', $karma['link'], '<br />
<span class="smalltext">
<strong>Karmas:</strong> ', $karma['karma'], '
</span>
</td>
</tr>';
echo '
</table>';
}
When I call the SSI function in index, it gives me some kind of "string" error. Can anyone tell me what I may be doing wrong? Normally, calling SSI functions in the index.template.php works perfectly. By the way, I do not have simple portals installed.
Website: http://biology-forums.com
-
Looks good. Moved to the Blocks and Modifications board. :)
you are master
-
Can someone update this please
Thanks
:D
-
This should work without any problem on SMF 2.0.2 :)
-
Yes it does i'm sorry delete post i was putting the code in html duh
-
Hi :)
With smf 2.0.2 Top Karmas avatars disappear but top poster avatars works perfectly, can you help me?
Thank you very much! :thumbsup:
-
Can you help me? :nervous-happy:
-
excuse me for bump but I need help with this code....
Thank you
;)
-
It does help if you state what the help you require is.
:nervous-happy:
-
Hi :)
With smf 2.0.2 Top Karmas avatars disappear but top poster avatars works perfectly, can you help me?
Thank you very much! :thumbsup:
:)
-
:in-love: Code Looks great.
I've modified the code a bit for other mod I have instead of karma.
For anyone who are interested to do so, you'll need knowledge on phpmyadmin, smf and a bit of php.
- Well, first login to your host.
- Open phpMyAdmin
- Find your SMF database.
- Search for "smf_members" without the quotes.
- By looking at the columns, other mod will also store a new filed. (example: "smf like" mod etc)
- Copy the name of the column. (example: installed_mod)
- Change the following to installed_mod for example:
- SELECT id_member, real_name, installed_mod
FROM {db_prefix}members
ORDER BY installed_mod DESC
- This will select installed_mod from the table called "members" then sort nstalled_mod from lowest value to the highest.
- This is it! You don't have to modify any other code, just hit save and you're done with a new rating system.
Preview:
Sorry, I've enabled this for members only. Please join here (http://chatngo.us.tc") before you can preview it.
I've renamed from karma to likes, since that what I use.
-
:in-love: Code Looks great.
I've modified the code a bit for other mod I have instead of karma.
For anyone who are interested to do so, you'll need knowledge on phpmyadmin, smf and a bit of php.
- Well, first login to your host.
- Open phpMyAdmin
- Find your SMF database.
- Search for "smf_members" without the quotes.
- By looking at the columns, other mod will also store a new filed. (example: "smf like" mod etc)
- Copy the name of the column. (example: installed_mod)
- Change the following to installed_mod for example:
- SELECT id_member, real_name, installed_mod
FROM {db_prefix}members
ORDER BY installed_mod DESC
- This will select installed_mod from the table called "members" then sort nstalled_mod from lowest value to the highest.
- This is it! You don't have to modify any other code, just hit save and you're done with a new rating system.
Preview:
Sorry, I've enabled this for members only. Please join here (http://chatngo.us.tc") before you can preview it.
I've renamed from karma to likes, since that what I use.
Hello,
I am not understanding point 8. What do you mean "SELECT id_member, real_name, installed_mod
FROM {db_prefix}members, ORDER BY installed_mod DESC"? Thank you, please either respond here (http://www.seocompanylosangeles.biz) or pm me.
-
Hmmm... is it possible to insert default membergroup color instead of been the same color for all names...