Need help hiding the search box from guests

Started by Tanks, February 12, 2010, 06:24:42 AM

Previous topic - Next topic

Tanks

Can i hide the search box from guests ?

I am on SMF 2.0 RC2 default curve theme

Edit: i managed to hide the home button using !$user_info['is_guest'],

Forum button i guess should not be hidden, even if they cant see the forum.

The thing i really want is to hide that search box, news is already hidden.

Kays

If you go into the permissions for Guests you can disable the ability for them to use the search feature. (Search for posts and topics) Then the search boxes will be disappeared for them.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Tanks

Hello Kays,

Yes that is also what i thought - but that only applies to the search button. Search field in the header is still shown.

Kays

That's weird, so they get an error message instead when they try. ::)

For the Curve (style) theme it's this in index.template.php.


echo '
</div>
<div class="news normaltext">
<form id="search_form" style="margin: 0;" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<input type="text" name="search" value="" class="input_text" />&nbsp;
<input type="submit" name="submit" value="', $txt['search'], '" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';


Add if ($context['user']['is_logged']) before it. (use $context, not $user_info)

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Tanks


Kays

Actually, in taking a closer look at it I missed a bit. It goes all of the way down to the begining of the news item.


if ($context['allow_search'])
{
echo '
<div id="news_section" class="titlebg2 clearfix"', empty($options['collapse_header']) ? '' : ' style="display: none;"', '>
<form class="floatright" id="search_form" action="', $scripturl, '?action=search2" method="post" accept-charset="', $context['character_set'], '">
<a href="', $scripturl, '?action=search;advanced" title="', $txt['search_advanced'], '"><img id="advsearch" src="'.$settings['images_url'].'/filter.gif" align="middle" alt="', $txt['search_advanced'], '" /></a>
<input type="text" name="search" value="" style="width: 190px;" class="input_text" />&nbsp;
<input type="submit" name="submit" value="', $txt['search'], '" style="width: 11ex;" class="button_submit" />
<input type="hidden" name="advanced" value="0" />';

// Search within current topic?
if (!empty($context['current_topic']))
echo '
<input type="hidden" name="topic" value="', $context['current_topic'], '" />';
// If we're on a certain board, limit it to this board ;).
elseif (!empty($context['current_board']))
echo '
<input type="hidden" name="brd[', $context['current_board'], ']" value="', $context['current_board'], '" />';

echo '
</form>';
}

// Show a random news item? (or you could pick one from news_lines...)


Also, if you change it back to what it was in Subs.php ($context['allow_search'']), then you can control both by using permissions.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Tanks

That's great but it works fine now. Guests can't see the search box, they can't see the news items, and the can not see the home button. All the can do is log in or register.  So I will not mess more with this. Thanks again.

Kays


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Advertisement: