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

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 02:07:55 AM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 86
  • Total: 86

Question about SMF coding

Started by jazz, May 12, 2005, 04:25:36 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jazz

I can't seem to get a reply to this at SMF, so I thought I'd post here.  If you don't want this type of question posted, feel free to delete it.  I won't get my feelings hurt.

In moving to TP, I've eliminated a menu bar.  Since I have removed the 2nd menu bar, I need to add a few buttons.  Admin is only viewable to Admin.  I want something similar, but to be viewed only by groups 22-28 or something similar.  I've tried the following code on index.template.

// Member List
if (count(array_intersect(range(22, 28), $user_info['groups'])) != 0){
echo '
<td><a href="http://mydomain.com/fcp/fcp.php">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/memberlist.gif" alt="' . $txt[802] . '" border="0" />' : $txt[802]), '</a></td>';
}


It doesn't work.  Is anyone willing to help figure out where I have the coding wrong?

Bjørn

Nah, just post it here. ;D Chances are I haven't seen it over there..so much to see, so little time...

I would probably just use an in_array for this:
// Member List
                $show=false;
                foreach($user_info['groups'] as $mgrp => $val){
                      if(in_array($val,array('22','23','24','25','26')))
                         $show=true;
                }
                if($show==true){
                  echo '
                                <td><a href="http://mydomain.com/fcp/fcp.php">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/memberlist.gif" alt="' . $txt[802] . '" border="0" />' : $txt[802]), '</a></td>';
                }


I am not sure why your original don't work, but to me this latter is more clear... probably not the most elegant. ;)

jazz

Thanks.  I'm getting the same error with this code.

2: Invalid argument supplied for foreach()
File: /home/carmmcom/public_html/members/Themes/default/TPortalBlocks.template.php (eval?)
Line: 1051

There isn't even 1051 lines in tportalblocks.

Bjørn

How about this one then?
// Member List
                $show=false;
                foreach($context['user']['groups'] as $mgrp => $val){
                      if(in_array($val,array('22','23','24','25','26')))
                         $show=true;
                }
                if($show==true){
                  echo '
                                <td><a href="http://mydomain.com/fcp/fcp.php">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/memberlist.gif" alt="' . $txt[802] . '" border="0" />' : $txt[802]), '</a></td>';
                }

jazz

Nope same message.  Is there something that I'm supposed to modify in the tportal files?

Bjørn

This is strange because it works in my installation...

jazz

Maybe it's a problem with where I'm placing it.  I'm placing it after

        // The [calendar]!

        if ($context['allow_calendar'])

                echo '<td><a href="', $scripturl, '?action=calendar">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/calendar.gif" alt="' . $txt['calendar24'] . '" style="margin: 0px 0;" border="0" />' : $txt['calendar24']), '</a></td>';


Is there a better place for it?

Bjørn

No, that place is fine..is the group ID's correct?