Display a 'Event Running Today' message in List view

Home Forums Calendar Products Events Calendar PRO Display a 'Event Running Today' message in List view

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1436964
    Brett
    Participant

    Hello 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!

    #1438602
    Brett
    Participant

    Sorry, managed to ask this question twice in the forum!

    • This reply was modified 8 years, 2 months ago by Brett.
    #1438974
    Sky
    Keymaster

    Brett,

    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,
    Sky

    #1439520
    Brett
    Participant

    Hi 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. 🙂

    #1439880
    Sky
    Keymaster

    Brett,

    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.php

    Since 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,
    Sky

    #1440375
    Brett
    Participant

    Hi 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.

    #1440622
    Sky
    Keymaster

    Brett,

    Awesome! Good luck!

    Sky

    #1440633
    Brett
    Participant

    Okay!

    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.

    • This reply was modified 8 years, 2 months ago by Brett.
    • This reply was modified 8 years, 2 months ago by Brett.
    #1441839
    Sky
    Keymaster

    Brett,

    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

    #1462076
    Support Droid
    Keymaster

    Hey 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

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Display a 'Event Running Today' message in List view’ is closed to new replies.