Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: fiver on April 19, 2010, 08:01:46 AM

Title: Statsbar next to each post.
Post by: fiver on April 19, 2010, 08:01:46 AM
SMF 2.0RC3

Hi,

There are Most Time Online statsbar under index.php?action=stats. I'd like to add that statsbar under the user name next to each post. With zero php knowledge, I tried copying the codes from Stats.php over to MessageIndex.php but nothing happens.

Really appreciate any help with the right codes. Thanks.
Title: Re: Statsbar next to each post.
Post by: fiver on April 21, 2010, 02:06:02 AM
I've put the following codes from memberlist into Display.template but still nothing happens


   if (!empty($context['members']))
   {
      foreach ($context['members'] as $member)
      {
                  if (!empty($member['post_percent']))
            echo '
                  <li class="bar" style="width: ', $member['post_percent'] + 4, 'px;">
                     <div style="width: ', $member['post_percent'], 'px;"><>
                  </li>';
      }
   }



Any suggestions from anyone please? Thanks.
Title: Re: Statsbar next to each post.
Post by: fiver on May 04, 2010, 09:10:12 AM
Bump after 2 weeks. :)


Really eager to get this working in the forum.
Title: Re: Statsbar next to each post.
Post by: Kays on May 04, 2010, 09:33:53 AM
Hi, it's not going to work the same way in Display.template.php. In Stats, there are queries run to get that info.

A member's time on line is in the profile as total_time_logged_in, But I don't known in what format is used in Display.php. Also if you want to show a % graph, you will need to do a query to find the user with the most time online.
Title: Re: Statsbar next to each post.
Post by: fiver on May 04, 2010, 10:37:12 AM
Hi Kays,


Thanks for the reply.


If it works in stats page and memberlist page, I wonder how to make it work in display.template.php so it shows next to each post.


Any suggestion is most welcome.
Title: Re: Statsbar next to each post.
Post by: Arantor on May 04, 2010, 10:38:20 AM
Both Stats.php and Memberlist.php run a query to get the highest poster that's applicable, which will have to be copied into Display.php (not the template) first...

Which stats bar, exactly, did you want?

A variant of http://custom.simplemachines.org/mods/index.php?mod=1929 might be relevant here.
Title: Re: Statsbar next to each post.
Post by: fiver on May 04, 2010, 10:53:09 AM
Hi Arantor,


Thanks for the recommendation. The mod requires setting a fix number as 100%.


I want the same statsbar in the memberlist to show next to each post please.
Title: Re: Statsbar next to each post.
Post by: Arantor on May 04, 2010, 11:23:46 AM
And which statsbar is that, exactly? The one relative to the highest post count?

Yay for encouraging spam (it worked on me, here)
Title: Re: Statsbar next to each post.
Post by: fiver on May 04, 2010, 12:04:28 PM
Spam????


OK, it's like the one under Post column:
http://www.simplemachines.org/community/index.php?action=mlist (http://www.simplemachines.org/community/index.php?action=mlist)
Title: Re: Statsbar next to each post.
Post by: Arantor on May 04, 2010, 12:07:36 PM
Spam doesn't have to be just bots trying to get you to their site - any post that is unwanted, duplicative, and generally made just to boost post count is often called spam too, and I think if you encourage users to post, you'll end up getting them just posting for the sake of posting if you're not careful.

You could, you know, try looking at the link I provided above because it might be useful... and likely to work on 2.0 RC3 without significant changes...
Title: Re: Statsbar next to each post.
Post by: fiver on May 04, 2010, 12:29:03 PM
LOL I had to deal with that since installing hidepost a few years ago, and members know that I don't mind them chit chatting but anyone trying to spam gets a warning or even a ban, and I've tried the warning system in SMF2RC3, it works ;D  . Touch wood, so far post count has encouraged more genuine posts than spam.



I had tried looking at that mod, I don't know how to change it so it will be based on the highest number of post. I thought using what is already there in stats and memberlist page will be consistent - members get confuse very easily when something doesn't 'click'.








Title: Re: Statsbar next to each post.
Post by: Arantor on May 04, 2010, 12:29:50 PM
You could always try asking the author, the mod's page seems to suggest it would actually do what you want.
Title: Re: Statsbar next to each post.
Post by: fiver on May 05, 2010, 03:16:40 AM
http://www.simplemachines.org/community/index.php?topic=321247.msg2598910#msg2598910

[/size]
Quote from: Nas on April 24, 2010, 01:33:09 PM
Sorry for all the delaying, I've been busy.

Since I no longer have the time or interest to keep updating my mods regularly, this and my other creations will have to wait for 2.0 Final before I update them or add any new features. Sorry.
Title: Re: Statsbar next to each post.
Post by: fiver on May 05, 2010, 03:20:04 AM
Hi Arantor,


Are you able to help me with the code changes?


I gather that Nas' mod put the database query into subs.php. Can I copy the one for memberlist and put it in subs.php?


Follow by the bits from memberlist template into display template right?
Title: Re: Statsbar next to each post.
Post by: fiver on May 05, 2012, 11:59:46 AM
SMF 2.0.2


Bump after 2 years.
Title: Re: Statsbar next to each post.
Post by: fiver on May 05, 2012, 12:54:51 PM
I transferred the SMF2.0.2 codes from memberlist into display.template. Still got no effect. Got an undefined error for "member" instead.