TinyPortal

General => Chit chat => Topic started by: jazz on May 12, 2005, 04:25:36 AM

Title: Question about SMF coding
Post by: jazz on May 12, 2005, 04:25:36 AM
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?
Title: Re: Question about SMF coding
Post by: Bjørn on May 12, 2005, 11:17:57 AM
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. ;)
Title: Re: Question about SMF coding
Post by: jazz on May 12, 2005, 06:23:25 PM
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.
Title: Re: Question about SMF coding
Post by: Bjørn on May 12, 2005, 06:36:47 PM
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>';
                }
Title: Re: Question about SMF coding
Post by: jazz on May 12, 2005, 06:48:05 PM
Nope same message.  Is there something that I'm supposed to modify in the tportal files?
Title: Re: Question about SMF coding
Post by: Bjørn on May 12, 2005, 08:09:30 PM
This is strange because it works in my installation...
Title: Re: Question about SMF coding
Post by: jazz on May 12, 2005, 08:15:21 PM
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?
Title: Re: Question about SMF coding
Post by: Bjørn on May 12, 2005, 11:08:00 PM
No, that place is fine..is the group ID's correct?