(2017-02-13, 10:34 PM)Wage Wrote: [ -> ]Show us the code that you're using.
This is in my
postbit_classic:
<if $post['regdate']+(60*60*24*30) <= TIME_NOW then><div class="postbit-time-1month">1 month on MMH</div></if>
<if $post['regdate']+(60*60*24*61) <= TIME_NOW then><div class="postbit-time-2month">2 months on MMH</div></if>
<if $post['regdate']+(60*60*24*182) <= TIME_NOW then><div class="postbit-time-halfyear">1/2 year on MMH</div></if>
<if $post['regdate']+(60*60*24*365) <= TIME_NOW then><div class="postbit-time-year">1 year on MMH</div></if>
And this is in my
global.css on my theme:
.postbit-time-1month {
width: 140px;
font-size: 11px;
text-align: center;
margin: 3px auto 0px auto;
padding: 4px 0px;
background: #181818;
border-radius: 3px;
}
.postbit-time-2month {
width: 140px;
font-size: 11px;
text-align: center;
margin: 3px auto 0px auto;
padding: 4px 0px;
background: #181818;
border-radius: 3px;
}
.postbit-time-halfyear {
width: 140px;
font-size: 11px;
text-align: center;
margin: 3px auto 0px auto;
padding: 4px 0px;
background: #181818;
border-radius: 3px;
}
.postbit-time-year {
width: 140px;
font-size: 11px;
text-align: center;
margin: 3px auto 0px auto;
padding: 4px 0px;
background: #181818;
border-radius: 3px;
}
Please, try this:
<if $post['regdate']+(60*60*24*30) <= TIME_NOW then>
<div class="postbit-time-1month">1 month on MMH</div>
<elseif $post['regdate']+(60*60*24*61) <= TIME_NOW then>
<div class="postbit-time-2month">2 months on MMH</div>
<elseif $post['regdate']+(60*60*24*182) <= TIME_NOW then>
<div class="postbit-time-halfyear">1/2 year on MMH</div>
<elseif $post['regdate']+(60*60*24*365) <= TIME_NOW then>
<div class="postbit-time-year">1 year on MMH</div>
</if>
(2017-02-14, 06:24 PM)SvePu Wrote: [ -> ]Please, try this:
<if $post['regdate']+(60*60*24*30) <= TIME_NOW then>
<div class="postbit-time-1month">1 month on MMH</div>
<elseif $post['regdate']+(60*60*24*61) <= TIME_NOW then>
<div class="postbit-time-2month">2 months on MMH</div>
<elseif $post['regdate']+(60*60*24*182) <= TIME_NOW then>
<div class="postbit-time-halfyear">1/2 year on MMH</div>
<elseif $post['regdate']+(60*60*24*365) <= TIME_NOW then>
<div class="postbit-time-year">1 year on MMH</div>
</if>
It got rid of the 2 boxes but it's left me on "1 month" yet i've been a member over 2?
Ok...you're right, but this should work:
<?php
switch($x)
{
case ($post['regdate']+(60*60*24*30) <= TIME_NOW):
echo '<div class="postbit-time-1month">1 month on MMH</div>';
break;
case ($post['regdate']+(60*60*24*62) <= TIME_NOW):
echo '<div class="postbit-time-2month">2 months on MMH</div>';
break;
case ($post['regdate']+(60*60*24*182) <= TIME_NOW):
echo '<div class="postbit-time-halfyear">1/2 year on MMH</div>';
break;
case ($post['regdate']+(60*60*24*365) <= TIME_NOW):
echo '<div class="postbit-time-year">1 year on MMH</div>';
break;
default:
echo '';
break;
}
echo $x;
?>
Worked a treat, thank you!
How can you remove 0 years of service lol?
very useful thanks for posting
(2015-07-19, 09:10 AM)Krytic Wrote: [ -> ]Or:
<setvar years>floor((TIME_NOW-$post['regdate'])/(60*60*24*365))</setvar>
<span class="service-{$GLOBALS['tplvars']['years']}">{$GLOBALS['tplvars']['years']} years of service</span>
(The number will be an integer, ie 1, 2, 3, instead of one, two, three)
Then, in global.css, stuff like this works:
.service-1 {
color: pink;
}
.service-2 {
color: yellow;
}
.service-3 {
color: red;
}
.service-4 {
color: orange;
}
et cetera, where the number is the number of years of service.
(2017-02-14, 07:24 PM)SvePu Wrote: [ -> ]Ok...you're right, but this should work:
<?php
switch($x)
{
case ($post['regdate']+(60*60*24*30) <= TIME_NOW):
echo '<div class="postbit-time-1month">1 month on MMH</div>';
break;
case ($post['regdate']+(60*60*24*62) <= TIME_NOW):
echo '<div class="postbit-time-2month">2 months on MMH</div>';
break;
case ($post['regdate']+(60*60*24*182) <= TIME_NOW):
echo '<div class="postbit-time-halfyear">1/2 year on MMH</div>';
break;
case ($post['regdate']+(60*60*24*365) <= TIME_NOW):
echo '<div class="postbit-time-year">1 year on MMH</div>';
break;
default:
echo '';
break;
}
echo $x;
?>
Thanks for the post. a good guide to customize
+1.
