Home › Forums › Calendar Products › Events Calendar PRO › Display no time when event is set to "all day"
- This topic has 7 replies, 2 voices, and was last updated 11 years, 2 months ago by
Barry.
-
AuthorPosts
-
February 3, 2015 at 7:03 am #939729
Nicola
ParticipantHello hello,
I have replaced
<?php echo tribe_events_event_schedule_details(); ?>with
<?php echo tribe_get_start_date( $post->ID, false, 'd M Y' ); ?> <?php echo tribe_get_start_date( $post->ID, false, 'g:ia' ); ?>Now when the event is set to “all day” the time output is 0:00 o’clock. I am looking for a way to change the time output to “all day” or not have it displayed at all.
Can you help me?
Kind Regards,
NicolaFebruary 3, 2015 at 7:10 am #939733Barry
MemberHi Nicola: you can use tribe_event_is_all_day() to detect if it is an all day event – and show or hide the time information appropriately 🙂
February 3, 2015 at 8:13 am #939752Nicola
ParticipantHello, I have tried this, but it does not work. I want to show the time only if it is not an all-day event.
<?php if ( (tribe_event_is_all_day == false) || ( int $postId = null ) ): ?> <?php echo tribe_get_start_date( $post->ID, false, 'G:i' ); ?> <?php endif ?>I don’t know php so this gives me a syntax error. Can you given me the correct syntax please.
Kind Regards,
NicolaFebruary 3, 2015 at 1:35 pm #939803Barry
MemberHi Nicola,
So to call a function you need to follow the function name with parentheses – so instead of just:
tribe_event_is_all_dayEnsure you follow up with ():
tribe_event_is_all_day()You might also want to modify the second part of the if clause — in PHP a single equals sign by itself is used to assign a value rather than to compare it (comparison can be done with a double == or treble === equals signs).
I definitely appreciate this sort of work can be tricky when you don’t know PHP, but please bear in mind if you decide to make customizations like this it is really your responsibility to understand what’s happening so you can maintain your work going forward – though of course we’re always happy to give you a pointer in the right direction if we can 🙂
Thanks again and I hope that helps!
February 4, 2015 at 1:32 pm #940056Nicola
ParticipantHello Barry,
thank you for your help so far, but I can’t seem to get it to work.Trying this code I think it should only proceed if the event is not an all-day event, but instead it does the opposite, it displays only the all-day events.
<?php if ( tribe_event_is_all_day(false) ): ?>Setting it to true does not change this.
February 4, 2015 at 4:42 pm #940097Barry
MemberHi there Nicola,
So I wouldn’t recommend passing in true or false in this situation. Unless you’re calling this function from somewhere unusual you probably need pass in nothing at all:
if ( tribe_is_all_day_event() ) { /*...*/ }It does optionally accept a single parameter, though, which should be the numeric ID of the event you are interested in (though you need only provide this in those rare situations where it isn’t obvious to WordPress/our plugin):
if ( tribe_is_all_day_event( 12345 ) ) { /*...*/ }I hope that clarifies things 🙂
February 16, 2015 at 8:17 am #942722Nicola
ParticipantHello, I still cant get it to work. The code you give me assumes that the attribute tribe_is_all_day_event is true and then execudes what is the {} brackets.
if ( tribe_is_all_day_event( 12345 ) ) { /*...*/ }But I would like to execude the code in the {} brackets only if the arguement is not true, if it is not an all-day-event.
Can you help me?
Kind reghards,
NicolaFebruary 16, 2015 at 9:01 am #942757Barry
MemberHi Nicola!
So you can do one of at least two things here — either test to see if the response is negative (using the ! operator):
if ( ! tribe_is_all_day_event( 12345 ) ) { /*...*/ }Or use an if/else structure:
if ( tribe_is_all_day_event( 12345 ) ) { /*...display things one way...*/ } else { /*...display things some other way...*/ }We’re always happy to try and point people in the right direction but since this is very much customization territory and the remaining stumbling blocks mostly seem to relate to PHP knowledge – and I’m afraid we just don’t have the resources to coach you through that – I’m going to go ahead and close out this topic.
Of course if any other issues crop up definitely do let us know and we’ll be happy to help as best we can 🙂
-
AuthorPosts
- The topic ‘Display no time when event is set to "all day"’ is closed to new replies.
