TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 468
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 227
  • Total: 227

Need Help Putting Profile Stats On Index Template

Started by Xarcell, September 01, 2008, 05:09:53 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Xarcell

I'm working on a new theme and was having problems added a user's profile stats to the index.template.php.

I'm trying to add:
', $txt['statPanel_total_time_online'], ':', $context['member']['registered'], ' <br />
', $txt['statPanel_total_time_online'], ':', $context['time_logged_in'], ' <br />
', $txt['statPanel_total_posts'], ': ', $context['num_posts'], ' ', $txt['statPanel_posts'], '<br />
', $txt['statPanel_total_topics'], ':', $context['num_topics'], ' ', $txt['statPanel_topics'], '<br />
', $txt['statPanel_users_polls'], ': ', $context['num_polls'], ' ', $txt['statPanel_polls'], '<br />
', $txt['statPanel_users_votes'], ': ', $context['num_votes'], ' ', $txt['statPanel_votes'], '<br />


However the stats will not load. Is it possible without altering any source files?

IchBin


Xarcell


IchBin

Do you get that on the index or the profile page?


IchBin

#5
Ah... I should have looked closer. Sorry the loadMemberContext is not necessary. I'm not sure what function calls those stats from the stats page. I'll take a look and see what I can find.


--edit--

Think I found it. Try this function instead.
http://support.simplemachines.org/function_db/index.php?action=view_function;id=346

Xarcell

#6
I'm still trying to learn the basic's of PHP, so would I use:

function statPanel (){
echo '
', $txt['statPanel_total_time_online'], ':', $context['member']['registered'], ' <br />
', $txt['statPanel_total_time_online'], ':', $context['time_logged_in'], ' <br />
', $txt['statPanel_total_posts'], ': ', $context['num_posts'], ' ', $txt['statPanel_posts'], '<br />
', $txt['statPanel_total_topics'], ':', $context['num_topics'], ' ', $txt['statPanel_topics'], '<br />
', $txt['statPanel_users_polls'], ': ', $context['num_polls'], ' ', $txt['statPanel_polls'], '<br />
', $txt['statPanel_users_votes'], ': ', $context['num_votes'], ' ', $txt['statPanel_votes'], '<br />';

}


If so, it isn't working...

Just for the record, I'm using 2.0 beta 3.1

IchBin

No problem on the learning part Xarcell, I'll try to teach what I know, or can figure out. Thats what its all about. So looking at SMF2 beta3 the statPanel still exists. If you look at the function on SMF it shows you that the function takes a parameter of memID being the members ID number. In doing so you get a return of all the stuff in the function. I'm not sure what it all entails until I can have a closer look. But from what I understand you have to called it something like this statPanel(3);  Three being the ID of the member. According the SMF's site this function now lives in the Profile-View.php file in SMF2. Which means you'll have to include that file to be able to call the function. I'll try to take a closer look at this tomorrow if I get a chance at work.

JPDeni

You have to declare global variables in a function. So your function would start out like


function statPanel (){
  global $context, $txt;


Assuming all of your variables have been defined before you call the function, it should work.

Xarcell

#9
I put the globals in, and the variables I used are from the profile template.

Even with the globals, it still doesn't work.

code used:


         function statPanel(){
            global $context, $txt;
echo '
', $txt['statPanel_total_time_online'], ':', $context['member']['registered'], ' <br />
', $txt['statPanel_total_time_online'], ':', $context['time_logged_in'], ' <br />
', $txt['statPanel_total_posts'], ': ', $context['num_posts'], ' ', $txt['statPanel_posts'], '<br />
', $txt['statPanel_total_topics'], ':', $context['num_topics'], ' ', $txt['statPanel_topics'], '<br />
', $txt['statPanel_users_polls'], ': ', $context['num_polls'], ' ', $txt['statPanel_polls'], '<br />
', $txt['statPanel_users_votes'], ': ', $context['num_votes'], ' ', $txt['statPanel_votes'], '<br />';

}


EDIT: I also tried "include" that file too, still no luck.

This website is proudly hosted on Crocweb Cloud Website Hosting.