Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: Joe N on June 27, 2009, 11:16:24 AM

Title: [Tip] Stats Tab
Post by: Joe N on June 27, 2009, 11:16:24 AM
Hi

This adds a Stats tab to your menu!

First, Go to index.template.php

Find:
// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
</td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


Code (Add After:) Select
// Show the [Stats] button
echo ($current_action == 'stats' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'stats' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=stats">' , $txt['stats_mod'] , '</a>
</td>' , $current_action == 'stats' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';




Now you will see a space after the member button

Now we have to go to modifications.english.php

Code (find (at the end of the file:) Select
?>

Code (add before) Select
$txt['stats_mod']= 'Stats';

Thanks For reading and I hope this helps!

Joe N

p.s. Also, if anyone has used it, please put there forum url so I can take a look

Title: Re: [Mod] Stats Tab
Post by: Marcus Forsberg on June 28, 2009, 04:58:26 AM
Hello.

Would oyu like to have this moved to Tips and Tricks (http://www.simplemachines.org/community/index.php?board=72.0)?
Title: Re: [Mod] Stats Tab
Post by: Joe N on June 28, 2009, 05:03:13 AM
Quote from: Nas on June 28, 2009, 04:58:26 AM
Hello.

Would oyu like to have this moved to Tips and Tricks (http://www.simplemachines.org/community/index.php?board=72.0)?

Yes Please
Title: Re: [Tip] Stats Tab
Post by: [Core] on June 30, 2009, 10:54:18 PM
Nice...
Title: Re: [Tip] Stats Tab
Post by: Joe N on July 01, 2009, 10:18:28 AM
Quote from: [Core28] on June 30, 2009, 10:54:18 PM
Nice...

Thank You!

Also, if anyone has used it, please put there forum url so I can take a look
Title: Re: [Tip] Stats Tab
Post by: LHW on July 01, 2009, 09:24:08 PM
Very nice!  I just added it to my place, and it works like a charm.  ;D

Thank you!

Oh...just click the gold image in my sig for the forum link.
Title: Re: [Tip] Stats Tab
Post by: [Core] on July 01, 2009, 10:59:21 PM
Quote from: Joe N on July 01, 2009, 10:18:28 AM
Quote from: [Core28] on June 30, 2009, 10:54:18 PM
Nice...

Thank You!

Also, if anyone has used it, please put there forum url so I can take a look

your welcome.
Title: Re: [Tip] Stats Tab
Post by: LHW on July 02, 2009, 04:51:19 PM
I added this after the comment line:

   if ($context['user']['is_logged'])

Now the Stats aren't viewable by Guests: only Members.
Title: Re: [Tip] Stats Tab
Post by: Bulakbol on July 04, 2009, 02:11:31 PM
If you want to use the group permission, use this
if (isset($context['show_stats']) && $context['show_stats'])
To enable permission for guests, go to Admin => Permissions => Permission by Membergroups, modify "Guests" permission, tick the  "View forum statistics" checkbox.
Title: Re: [Tip] Stats Tab
Post by: LHW on July 05, 2009, 05:35:54 PM
Quote from: Bulakbol on July 04, 2009, 02:11:31 PM
If you want to use the group permission, use this
if (isset($context['show_stats']) && $context['show_stats'])
To enable permission for guests, go to Admin => Permissions => Permission by Membergroups, modify "Guests" permission, tick the  "View forum statistics" checkbox.

I tried that.  After you click on the STATS button, the button disappears from the menu bar when the Stats Page is displayed.

Also, if you use the Tip as posted, or with
Quote from: Lord High Warlock on July 02, 2009, 04:51:19 PM
if ($context['user']['is_logged'])

The STATS button is not selected / highlighted as others would be when the Stats Page is displayed...it selects the HOME button.  Is there a way to correct this??
Title: Re: [Tip] Stats Tab
Post by: Bulakbol on July 07, 2009, 10:04:37 PM
Yes. Sorry 'bout that. I forgot that the $context['show_stats'] is only available in board index.
To highlight the stats tab, in index,template.php, look for
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

and add after
if ($context['current_action'] == 'stats')
$current_action = 'stats';
Title: Re: [Tip] Stats Tab
Post by: LHW on July 07, 2009, 11:09:58 PM
Thanks, Bulakbol!  That worked perfectly!

Kudos to you!  :D
Title: Re: [Tip] Stats Tab
Post by: JeremyB. on July 14, 2009, 03:42:47 AM
Thanks For the Tip.
Title: Re: [Tip] Stats Tab
Post by: JeremyB. on July 15, 2009, 03:20:55 AM
Some Translations:

Spanish:
$txt['stats_mod']= 'Estadísticas';

Polish:
$txt['stats_mod']= 'Statystyki';

Do you mind if I add to those boards?

-JB
Title: Re: [Tip] Stats Tab
Post by: Joe N on July 16, 2009, 01:02:16 PM
SURE JB
Title: Re: [Tip] Stats Tab
Post by: JeremyB. on July 16, 2009, 08:37:20 PM
Thanks.
Title: Re: [Tip] Stats Tab
Post by: Joe N on July 17, 2009, 06:52:47 AM
Quote from: JeremyB. on July 16, 2009, 08:37:20 PM
Thanks.

Hey

Could I have the link for ur site so I can take a look?
Title: Re: [Tip] Stats Tab
Post by: JeremyB. on July 17, 2009, 08:07:20 AM
A link to what site?
Title: Re: [Tip] Stats Tab
Post by: H on July 17, 2009, 08:28:30 AM
Quote from: JeremyB. on July 17, 2009, 08:07:20 AM
A link to what site?

The site where you're using this tip.
Title: Re: [Tip] Stats Tab
Post by: JeremyB. on July 17, 2009, 08:32:14 AM
Oh I'm not using just translated it.
Title: Re: [Tip] Stats Tab
Post by: Joe N on July 17, 2009, 11:07:20 AM
Oh ok

Thanks Anyway!