MyBB Hacks

Full Version: Question about Template Conditionals and XThreads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

First of all I would like to say that I have been visiting this forum for a year or more to find information, and I have always gotten it, I have never registered because I have never needed to ask for help, since I have always managed to do everything I needed for my forum. I would like to thank especially ZiNGA BuRgA and RateU for the many years of help and free work so that others can satisfy their forums, thank you very much, really.

What I need is to do is the following:

I use an Xthreads field to show the start date of an offer, and what I need is NOT to show the start date in the case that offer has expired.

For example:
An offer starts on 07/19/2019, so what I need is not to show the date information when it is already 07/20/2019.

What I need to insert into the Display Format input of a Custom Thread Field is something like this:

<if $datenow > {VALUE} then>This offer has already started<else><span class="xdate">Start the day: {VALUE}</span></if>

If someone can help me, it would make me very happy.

Thanks, and best regards!
I don't know what is the value of the $datenow variable.

You can use Unix timestamps format to compare them.
You can convert your date into Unix timestamps by using strtotime().

Something like this:

Code:
<if time() > strtotime({VALUE}) then>This offer has already started<else><span class="xdate">Start the day: {VALUE}</span></if>


Sorry for late reply.

I'm really sorry, RateU. I've been on family summer holidays, but I'm already here.

I've been testing for 4 hours and ... I've finally got it! Yipi Yes

PHP Code:
<?php 
$day = date("d");
$month = date("m");
$year = date("Y");
$total = strtotime("$year-$month-$day");
$va0 = {VALUE};
$va1 = {VALUE$1};
$va2 = {VALUE$2};
$va3 = {VALUE$3};
$total2 = strtotime("$va3-$va2-$va1");
$result = ($total <= $total2 and $total2 <> $total);

if ( $result == true) {
echo "<span class=\"xdate\">Start the day: {$va0}</span>";

}else {

echo "This offer has already started";

}

?>


I'm really happy, because I do not program php, but this code is exactly what I need. And above all thanks to you, RateU, this would not have been possible without your idea about strtotime ().

And I take the opportunity to say that thanks to the PHP And Template Conditionals & Xthreads plugins, I have managed to set up an incredibly advanced portal that I will release to the public in the coming weeks.

If you're interested in seeing it, RateU, let me know and I'll show you the URL by private message in the next few weeks, since right now I'm working on localhost.

Thank you very much again, my friends RateU and ZiNGA BURgA, I wish you the best in life, for all the years of work and help to MyBB users.

Glad you can solve the problem Smile
Reference URL's