Home › Forums › Calendar Products › Events Calendar PRO › Display a 'Event Running Today' message in List view
- This topic has 10 replies, 2 voices, and was last updated 8 years, 1 month ago by
Brett.
-
AuthorPosts
-
January 26, 2018 at 7:16 am #1436964
Brett
ParticipantHello again,
I am wondering if there is a way to display a message when an event is running on the day in List view, like an ‘Event runs today’ message?
The reason I want this, is because I currently have a message which says if an event is fully booked, however there seems to be a bit of a conflict when the event is running today and doesn’t display my message entirely so would rather display a different message entirely.
I currently have this written in my child theme’s /tribe-events/list/single-event.php:
It’s saying that if the Event’s start date is the same as the current date, display ‘-‘ else display ‘–‘ but it’s showing them all the same.
my knowledge of PHP is very basic, though I am trying to learn as I go along so forgive me if what I have makes 0 sense.
Also, I am sorry if this isn’t the right place to post this, I am struggling with something that I feel should be quite straight forward!
January 29, 2018 at 1:17 am #1438602Brett
ParticipantSorry, managed to ask this question twice in the forum!
-
This reply was modified 8 years, 2 months ago by
Brett.
January 29, 2018 at 9:27 am #1438974Sky
KeymasterBrett,
Can you post your custom code for me to take a look at? It would be best if you can paste it in something like https://www.pastiebin.com/ and share the link here.
I’ll take a look and see if I can spot why it’s not working properly.
Thanks,
SkyJanuary 30, 2018 at 2:06 am #1439520Brett
ParticipantHi Sky,
Thank you, of course. There’s not much code in what I have put together (at all) but maybe it will give an idea of what I’m trying to do…
https://www.pastiebin.com/5a704338b2f3d
Thank you. 🙂
January 30, 2018 at 9:34 am #1439880Sky
KeymasterBrett,
The code you have provided doesn’t make much sense out of context. Where are those variables being defined? Is this in context of the original template code?
I am limited in the amount of support I can provide for a customization like this. That being said, I can try to point you in the right direction, but you may need to find a PHP developer to help you out further.
You are basically needing to compare the event date with the current date. Here are the PHP functions that you need for each:
1) Event date – tribe_get_start_date() – https://theeventscalendar.com/function/tribe_get_start_date/
2) Today’s date – date() – http://php.net/manual/en/function.date.phpSince both of these return a string, you will need to make sure they are both formatted the same before doing a comparison.
I hope this helps! If you are able to get it working, feel free to post your solution here for others looking to do something similar.
Thanks,
SkyJanuary 31, 2018 at 1:19 am #1440375Brett
ParticipantHi Sky,
Thank you for your reply.
Nope, the variables were not being defined and the code was as vague for me as it was for you! Haha
Thank you for your guidance, this will help start me off greatly.
January 31, 2018 at 8:12 am #1440622Sky
KeymasterBrett,
Awesome! Good luck!
Sky
January 31, 2018 at 8:19 am #1440633Brett
ParticipantOkay!
I have done something that works exactly as I need it to:
`$EventStartDate = tribe_get_start_date();
$CurrentDate = date(“Y-m-d”);
if ($EventStartDate > $CurrentDate) : ?>`
(I can’t seem to put open and close php tags for some reason)
As you will never see any previous courses in list view, this works perfectly.
Thanks for your guidance, Sky. Helped a bunch.
February 1, 2018 at 9:02 am #1441839Sky
KeymasterBrett,
Glad I could help!
I’m going to change this ticket to “resolved.” Let us know if you have any other questions or issues in the future.
Sky
February 23, 2018 at 8:35 am #1462076Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
This reply was modified 8 years, 2 months ago by
-
AuthorPosts
- The topic ‘Display a 'Event Running Today' message in List view’ is closed to new replies.
