Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Question about Template Conditionals and XThreads
xho Offline
Junior Member
**
Posts: 2
Joined: Jul 2019
Post: #1
Question about Template Conditionals and XThreads
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!
07-01-2019 07:02 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #2
RE: Question about Template Conditionals and XThreads
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.


07-03-2019 10:52 PM
Find all posts by this user Quote this message in a reply
xho Offline
Junior Member
**
Posts: 2
Joined: Jul 2019
Post: #3
RE: Question about Template Conditionals and XThreads
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?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.

07-11-2019 04:54 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #4
RE: Question about Template Conditionals and XThreads
Glad you can solve the problem Smile

07-12-2019 01:15 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: