Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Aiheen aloitti: Jackson Cage - maaliskuu 06, 2005, 11:19:23 AP

Otsikko: I Want To Hide A Button
Kirjoitti: Jackson Cage - maaliskuu 06, 2005, 11:19:23 AP
I recently added a new button to my members only forum. Is there any way I can make that button acccessable ONLY if you're signed on as a member ???
Otsikko: Re: I Want To Hide A Button
Kirjoitti: Louis (CSpotkill) - maaliskuu 06, 2005, 12:29:10 IP
I'm assuming you're editing a theme file directly. Try adding the following around your button:
if ($context['user']['is_logged'])
{
echo 'Button Goes Here';
}

If you're editing template_menu(), see the "// If the user is a guest, show [login] and [register] buttons." for an example.
Otsikko: Re: I Want To Hide A Button
Kirjoitti: Jackson Cage - maaliskuu 07, 2005, 10:31:43 IP
Lainaus käyttäjältä: Jackson Cage - maaliskuu 06, 2005, 11:19:23 AP
I recently added a new button to my members only forum. Is there any way I can make that button acccessable ONLY if you're signed on as a member ???

I couldn't really follow what you were saying. What I did is cut and paste a button code that wasn't showing while you were logged off. Then I added another button. It worked until I added the second button.

This is my  code

// Otherwise, they might want to [logout]...
   else
       
        echo '
            <a href="http://client1.sigmachat.com/sc.pl?id=94058">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/chat.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
       
        echo '
            <a href="http://www.thejacksoncage.com/pictures/pics.html">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/pics.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
           
        echo '
            <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/logout.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';



The first button CHAT doesn't show up and niether does the last button LOGOUT but the PICS button in between does showup. What am I doing wrong ??
Otsikko: Re: I Want To Hide A Button
Kirjoitti: Louis (CSpotkill) - maaliskuu 07, 2005, 10:42:09 IP
Insert the following just before // If the user is a guest, show [login] and [register] buttons. (shown):

if ($context['user']['is_logged'])
{
        echo '<a href="http://client1.sigmachat.com/sc.pl?id=94058">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/chat.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
       
        echo '<a href="http://www.thejacksoncage.com/pictures/pics.html">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/pics.gif" alt="' . $txt[108] . '" style="margin: 2px 0;" border="0" />' : $txt[108]), '</a>';
}
// If the user is a guest, show [login] and [register] buttons.

Now does what I posted make more sense? It basically says, in English, "if user is logged in, show the stuff between the braces".

Also, make sure both chat.gif and pics.gif are in \themes\default\images\english\ (or similar)
Otsikko: Re: I Want To Hide A Button
Kirjoitti: Jackson Cage - maaliskuu 08, 2005, 07:58:05 AP
That worked. Thank you very much for your help.