News:

Wondering if this will always be free?  See why free is better.

Main Menu

Hide content to non-guests

Started by brettuk, July 22, 2018, 07:18:42 AM

Previous topic - Next topic

brettuk

Hi,

I have added some buttons to my header, however, I would like to only show them to guests and not members that are logged in.

Is there an easy way to hide content to members that are logged in?

Cheers

Steve

DO NOT pm me for support!

Antes


brettuk

#3
Yep it is @Steve.

@antes - thanks for replying, how do I implement this?

The buttons are within the .quick_search_holder div class, I have replaced the search functionality and put the image buttons in there.

Thanks for your help.

Edit:

Here's the code:

<div class="headerm">
<div class="headerm_inner" style="width: ', !empty($settings['forum_width']) ? $settings['forum_width'] : '' ,'">

<div class="logo_banner">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="' . $settings['images_url'] . '/theme/logo.png" alt="' . $context['forum_name'] . '" />' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
</div>

<div class="quick_search_holder">
<div class="sp_block">
<a href="register/"><img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px"></a><a href="login/"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Register An Account"></a>
</div>
</div>

</div>
</div>

brettuk

I can't seem to find a solution for this, however, I understand that a php IF statement is required, though.

SychO

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

something like this:
<div class="headerm">
<div class="headerm_inner" style="width: ', !empty($settings['forum_width']) ? $settings['forum_width'] : '' ,'">

<div class="logo_banner">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="' . $settings['images_url'] . '/theme/logo.png" alt="' . $context['forum_name'] . '" />' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
</div>';

if($context['user']['is_guest']) {
echo'
<div class="quick_search_holder">
<div class="sp_block">
<a href="register/"><img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px"></a><a href="login/"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Register An Account"></a>
</div>
</div>';
}

echo'
</div>
</div>


you can add an ELSE statement to choose what to show if they are registered
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

brettuk

Works perfectly, thank you very much :)

brettuk

What would be even better is if the IF else statement was to set the opacity of the images to 0.2.

So if they're logged in, they're still there, just lowered opacity. Is this doable?

SychO

<div class="headerm">
<div class="headerm_inner" style="width: ', !empty($settings['forum_width']) ? $settings['forum_width'] : '' ,'">

<div class="logo_banner">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="' . $settings['images_url'] . '/theme/logo.png" alt="' . $context['forum_name'] . '" />' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
</div>';

if($context['user']['is_guest']) {
echo'
<div class="quick_search_holder">
<div class="sp_block">
<a href="register/"><img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px"></a><a href="login/"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Login"></a>
</div>
</div>';
} else {
echo'
<div class="quick_search_holder">
<div class="sp_block">
<img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px;opacity:0.2"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Login" style="opacity:0.2">
</div>
</div>';
}

echo'
</div>
</div>
Checkout My Themes:
-

Potato  •  Ackerman  •  SunRise  •  NightBreeze

brettuk

Quote from: SychO on July 23, 2018, 07:48:25 AM
<div class="headerm">
<div class="headerm_inner" style="width: ', !empty($settings['forum_width']) ? $settings['forum_width'] : '' ,'">

<div class="logo_banner">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="' . $settings['images_url'] . '/theme/logo.png" alt="' . $context['forum_name'] . '" />' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
</div>';

if($context['user']['is_guest']) {
echo'
<div class="quick_search_holder">
<div class="sp_block">
<a href="register/"><img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px"></a><a href="login/"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Login"></a>
</div>
</div>';
} else {
echo'
<div class="quick_search_holder">
<div class="sp_block">
<img src="/Themes/letschatlove/images/register-mobile.png" alt="Register An Account" style="margin-right:20px;opacity:0.2"><img src="/Themes/letschatlove/images/login-mobile.png" alt="Login" style="opacity:0.2">
</div>
</div>';
}

echo'
</div>
</div>


That's perfect, thank you very much!

Advertisement: