Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: m3talc0re on July 13, 2008, 11:15:38 PM

Title: Hiding random news if no news is available.
Post by: m3talc0re on July 13, 2008, 11:15:38 PM
Right now, if you have no news available for the random news box in the header, you'll see the space for it and the News: text without any news showing. To turn that off, you have to go to another settings area and disable the random news item altogether. A quick and easy fix for this is to simply hide it if no news is available.

Open the index.template.php and find this:

// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']))
echo '
<td width="90%" class="titlebg2">
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
</td>';


See the if statement? This is what you want (notice the if again):

// Show a random news item? (or you could pick one from news_lines...)
if ((!empty($settings['enable_news'])) && (!empty($context['random_news_line'])))
echo '
<td width="90%" class="titlebg2">
<span class="smalltext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
</td>';
Title: Re: Hiding random news if no news is available.
Post by: metallica48423 on July 21, 2008, 03:00:06 AM
Hey thanks for the tip!

I had actually been looking for something like this for awhile.  Thanks!