TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,970
  • Latest: bynw
Stats
  • Total Posts: 196,055
  • Total Topics: 21,337
  • Online today: 201
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 138
  • Total: 139
  • lurkalot

how to set condition to show only on homepage?

Started by raid, April 15, 2008, 01:15:21 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

raid

hi all,

I wrote this little condition,
// Show a random news item? (or you could pick one from news_lines...)
if (!empty($settings['enable_news']) && (!$settings['show_newsfader']))
echo '
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
         <tr>
<td valign="top" height="15" class="smalltext" style="padding-left:10px;">
<b>', $txt[102], '</b>: ', $context['random_news_line'], '
</td>
</tr>
</table>';

editing an old one took from dilbermc I think.

there is a way to show this table only on tiny front page?

thx
SMF 2.0 + TP RC2

Jpg

This should work on most themes:

if ($current_action == 'home'){
echo '
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
         <tr>
<td valign="top" height="15" class="smalltext" style="padding-left:10px;">
<b>', $txt[102], '</b>: ', $context['random_news_line'], '
</td>
</tr>
</table>';
}

IchBin

Jpg, that code will not work unless you put it inside the template_menu function. With that code you will probably receive undefined variable: $current_action. You are taking the $current_action variable out of scope. Instead you should use:
if ($context['TPortal'][is_front] == 1)

Jpg

Oh then it'll be-
if ($context['TPortal'][is_front] == 1){
echo '
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
         <tr>
<td valign="top" height="15" class="smalltext" style="padding-left:10px;">
<b>', $txt[102], '</b>: ', $context['random_news_line'], '
</td>
</tr>
</table>';

}

raid

SMF 2.0 + TP RC2


raid

well, I have a problem.

I have lots of "Use of undefined constant is_front" into the Error's log

I think it is:
if (!empty($settings['enable_news']) && ($context['TPortal'][is_front] == 1))
echo '
        <table width="100%" cellpadding="0" cellspacing="0" border="0">
         <tr>
<td valign="top" height="15" class="catbg2" style="padding-left:10px;">
<span class="middletext"><b>', $txt[102], '</b>: ', $context['random_news_line'], '</span>
</td>
</tr>
</table>';


how to fix it?
SMF 2.0 + TP RC2

JPDeni


raid

SMF 2.0 + TP RC2

G6Cad


This website is proudly hosted on Crocweb Cloud Website Hosting.