collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 473
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: [SMF 2.0.2] Block 'top 5 most 'liked' members  (Read 16572 times)

0 Members and 1 Guest are viewing this topic.

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #20 on: October 25, 2012, 05:26:12 PM »
Hey, Underdog, was wondering if you could look this one over for me.  It works perfectly, the main issue is it causes heavy load time when the block is displayed, or when modifying it and clicking the 'Preview' button.  Load time goes back to normal when the block is not displayed.  Not sure if I've got unnecessary coding in there or it's just written in a way it is causing stress to the database calls.

Preview:



Code: [Select]
global $smcFunc, $scripturl, $context, $settings, $txt, $boardurl;

$result = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.real_name, lm.id_member, lm.id_message, lm.timestamp, msg.id_msg, msg.subject, msg.id_topic
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}likes AS lm ON (lm.id_member = mem.id_member)
LEFT JOIN {db_prefix}messages AS msg ON (msg.id_msg = lm.id_message)
ORDER BY timestamp DESC
LIMIT 5');

while ($row = $smcFunc['db_fetch_assoc']($result))
{
echo'<img src="', $settings['default_images_url'], '/admin/custom_like.png" height="10" />&nbsp;<a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$row['real_name'].'</a><font size="1"> Liked </font> <a href="'.$scripturl.'?topic='.$row['id_topic'].'.msg'.$row['id_message'].'#msg'.$row['id_message'].'" />' . $row['subject'] . '</a><br><hr>';
}
$smcFunc['db_free_result']($result);


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #21 on: October 26, 2012, 12:38:03 AM »
hcfwesker & kobar,

  I meant to mention to the both of you that attempting to display data smack in the middle of a db query is taboo. It is more prudent to put the needed data into an array, free the query & then do whatever you want with the array. I will skip back to the previous block code & edit it to be correct.



hcfwesker,

  I downloaded that mod to test this but the likes table did not contain all the columns you are selecting. I will assume you have edited the mod or perhaps are using its pro version. With that said, I was not able to test the code shown below. HTML & the db query were corrected.

Code: [Select]
global $smcFunc, $scripturl, $settings;

$result = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.real_name, lm.id_message, lm.timestamp, msg.subject, msg.id_topic
FROM {db_prefix}members AS mem
LEFT JOIN {db_prefix}likes AS lm ON (lm.id_member = mem.id_member)
LEFT JOIN {db_prefix}messages AS msg ON (msg.id_msg = lm.id_message)
ORDER BY timestamp DESC
LIMIT 5');

while ($row = $smcFunc['db_fetch_assoc']($result))
$likes[] = array('id_member' => $row['id_member'],'name' => $row['real_name'], 'topic' => $row['id_topic'], 'id_message' => $row['id_message'], 'subject' => $row['subject']);

$smcFunc['db_free_result']($result);

foreach ($likes as $mem => $data)
echo '<img src="', $settings['default_images_url'], '/admin/custom_like.png" style="height:10px;" />&nbsp;<a href="'.$scripturl.'?action=profile;u='.$data['id_member'].'">',$data['name'],'</a><span style="font-size:1em;"> Liked </span><a href="'.$scripturl.'?topic='.$data['topic'].'.msg'.$data['id_message'].'#msg'.$data['id_message'].'">' . $data['subject'] . '</a><br /><hr />';
« Last Edit: October 26, 2012, 01:02:30 AM by Underdog »

Offline hcfwesker

  • Semi Newbie
  • *
  • Posts: 43
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #22 on: October 26, 2012, 02:24:18 AM »
I'm new to retrieving info from the database, so to leanr I'm using other codes I see from MODs, and some in here for other blocks.

Thanx for the info, will keep that noted on future attempts.  :)

And, Yes, I am using the Pro Likes version, the Lite version doesn't allow you to like posts, just first post of a topic.  And I'm not sure if it keeps track of the timestamp either.

Thanx for your kind help and guidance.

Offline Kobar

  • Semi Newbie
  • *
  • Posts: 42
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: [SMF 2.0.2] Block 'top 5 most 'liked' members
« Reply #23 on: October 26, 2012, 04:10:29 AM »
Thank you so much, both of you!