News:

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

Main Menu

Hide news from guests

Started by ScousePete, October 14, 2006, 05:34:28 PM

Previous topic - Next topic

ScousePete

SMF Version: SMF 1.1 RC3
I would like to hide the news box from guests in the log-in screen.

I know that I need to add:
if ($context['user']['is_logged'])

to somewhere before:
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<div class="headertitles" style="width: 260px;"><img src="', $settings['images_url'], '/blank.gif" height="12" alt="" /></div>
<div class="headerbodies" style="width: 260px; position: relative; background-image: url(', $settings['images_url'], '/box_bg.gif); margin-bottom: 8px;">
<img src="', $settings['images_url'], '/', $context['user']['language'], '/newsbox.gif" style="position: absolute; left: -1px; top: -16px;" alt="" />
<div style="height: 50px; overflow: auto; padding: 5px;" class="smalltext">', $context['random_news_line'], '</div>
</div>';


on index.template.php, but I am not sure of the correct syntax.

Can someone help?

winrules

Find:
if (!empty($settings['enable_news']))
Replace With:
if (!empty($settings['enable_news']) && $context['user']['is_logged'])

Basically you just need to add it on to the if statement seeing if th enews is enabled.


winrules
SMF Developer
               
My Mods
Please do not PM me for support.


ScousePete

Excellent (and fast!) - thank you so much!

joejackson

Doesn't work for me.
Newsbox remains visible to all

Joomla 1.0.12
SMF 1.1.2
SMF bridge 1.1.7

KitKat2

Is there a more current way to hide the scrolling news from guests and unregistered users?  I have a few themes on my forum and one of them doesn't show the scrolling news to guests, but the others do so I'm thinking there's a setting I'm missing that I can just turn on or off instead of having to fiddle with the code.

Aleksi "Lex" Kilpinen

No, news has no permissions to it. If a specific theme works differently from the rest, it's the theme.

Edit:
Most every theme does have it's own setting for the news and it's layout though, it's "Enable random news line in the forum header " and "Show news fader on board index". See Admin -> Configuration -> Themes and Layout -> Theme settings
This has been the case pretty much always.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

KitKat2

#6
ok, thank you!

p.s.  just used the instructions above from 2006 and the code replacement still works today, almost 2025, on v 2.0.x (yeah, i know.  I need to update, but my main theme doesn't work on v. 2.1.x)

Advertisement: