MyBB Community Forums

Full Version: if Statements
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am currently using this - {$newposts} to display the amount of posts made today on my forum
Is it possible to have an if statement so I can do something like this -

if {$newposts} = 10 then "display this message"
else
"display this message2"
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
}
(2015-12-01, 07:56 PM)Sazze Wrote: [ -> ]
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
}

When I put that into my index template it doesn't work at all. Am I doing something wrong?
(2015-12-01, 07:58 PM)kingcool52 Wrote: [ -> ]
(2015-12-01, 07:56 PM)Sazze Wrote: [ -> ]
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
}

When I put that into my index template it doesn't work at all. Am I doing something wrong?

Because you need to get a plugin that allows PHP in templates: http://community.mybb.com/thread-31860.html

Make sure to include <?php & ?> parts like this:

<?php
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
} 
?>

After that you can use {$msg} variable.
(2015-12-01, 08:02 PM)Sazze Wrote: [ -> ]
(2015-12-01, 07:58 PM)kingcool52 Wrote: [ -> ]
(2015-12-01, 07:56 PM)Sazze Wrote: [ -> ]
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
}

When I put that into my index template it doesn't work at all. Am I doing something wrong?

Because you need to get a plugin that allows PHP in templates: http://community.mybb.com/thread-31860.html

Make sure to include <?php & ?> parts like this:

<?php
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
} 
?>

After that you can use {$msg} variable.

Still nothing. The code appears grey in the index template.
What do you mean by - "After that you can use {$msg} variable."
(2015-12-01, 08:06 PM)kingcool52 Wrote: [ -> ]
(2015-12-01, 08:02 PM)Sazze Wrote: [ -> ]
(2015-12-01, 07:58 PM)kingcool52 Wrote: [ -> ]
(2015-12-01, 07:56 PM)Sazze Wrote: [ -> ]
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
}

When I put that into my index template it doesn't work at all. Am I doing something wrong?

Because you need to get a plugin that allows PHP in templates: http://community.mybb.com/thread-31860.html

Make sure to include <?php & ?> parts like this:

<?php
if($newposts >= 10) {
$msg = "display";
}
elseif($newposts <= 10) {
$msg = "no";
} 
?>

After that you can use {$msg} variable.

Still nothing. The code appears grey in the index template.
What do you mean by - "After that you can use {$msg} variable."

Give me your template code.
Thanks for the help Wink
Its not working...
can any one help?

How to show like this in template:
<tr>
                                    <td style="background: #303030; border-bottom: 1px solid #151515; color: #fff; font-weight: 400; border-radius: 2px 2px 0 0;" colspan="4" align="left">Daily Post Goal</td>
                                </tr>

 <tr>
<td style="padding: 8px 10px;" width="15%" valgin="middle" align="left" class="trow1">Progress:</td>
<td style="padding: 8px 10px;" valgin="middle" width="10%" align="right" class="trow2">2400/4000 // 4001/4000</td>
</tr>

<tr>
<td style="padding: 8px 10px;" width="15%" valgin="middle" align="left" class="trow1">Status:</td>
<td style="padding: 8px 10px;" valgin="middle" width="10%" align="right" class="trow2"><span style="color: #f33;">Not Reached/Reached</span></td>
</tr>

(2015-12-30, 09:48 AM)Dr_The_One Wrote: [ -> ]Its not working...
can any one help?

How to show like this in template:
<tr>
                                    <td style="background: #303030; border-bottom: 1px solid #151515; color: #fff; font-weight: 400; border-radius: 2px 2px 0 0;" colspan="4" align="left">Daily Post Goal</td>
                                </tr>

 <tr>
<td style="padding: 8px 10px;" width="15%" valgin="middle" align="left" class="trow1">Progress:</td>
<td style="padding: 8px 10px;" valgin="middle" width="10%" align="right" class="trow2">2400/4000 // 4001/4000</td>
</tr>

<tr>
<td style="padding: 8px 10px;" width="15%" valgin="middle" align="left" class="trow1">Status:</td>
<td style="padding: 8px 10px;" valgin="middle" width="10%" align="right" class="trow2"><span style="color: #f33;">Not Reached/Reached</span></td>
</tr>


I can't see if statement codes there.
Can anyone give proper code for that?
Pages: 1 2