Home › Forums › Calendar Products › Events Calendar PRO › Remove End Date if same as Start Date
- This topic has 12 replies, 2 voices, and was last updated 13 years ago by
Barry.
-
AuthorPosts
-
April 18, 2013 at 9:08 am #46228
chirocare
ParticipantHello, we are wondering if there is a way to hide the end date if it is the same as the start date. Right now, it looks like this:
——————
Start: May 11, 2013 8:00 am
End: May 11, 2013 12:00 pm
——————
Ideally, if the start and end date are the same, it could look like this:
——————
Date: May 11, 2013
Time: 8:00 am – 12:00 pm
——————
Is there any way around this via the interface or do we have to make custom template adjustments? It does seem a little bit redundant to have the date twice — my guess is most people would prefer the suggested alternative. Thoughts?Thanks.
April 18, 2013 at 9:16 am #46231chirocare
ParticipantI looked in the list.php template, where I see this is outputted… and there is a conditional for
My events are not set to be all day events, but somehow they are getting stuck in this conditional. Any ideas why?
April 18, 2013 at 9:19 am #46233chirocare
ParticipantOops, the code didn’t come through on that last one. I was trying to show:
—–
if (tribe_is_multiday() || !tribe_get_all_day()):
—–
Both of these are outputting nothing (i.e. not true), so the second condition is what is catching us here. If I remove this, it displays (for the event I’m looking at now):
———–
Date: April 27, 2013 8:00 am
———–
However, now we are missing the end time. Thoughts?April 18, 2013 at 9:23 am #46235Barry
MemberHi chirocare. Just because I’d like to be sure I’m not missing anything from your explanation, can you share the amended code using Pastebin, Gist or a similar service (and paste the link in here)?
April 18, 2013 at 9:35 am #46237chirocare
ParticipantAll right, I made some changes to my list.php and single.php templates. I don’t really like modifying the templates if I can help it, but it seems like this may be the way to do here.
In list.php:
—————
+ Removed the “|| !tribe_get_all_day()” from the conditional on line 51
+ Changed the date display to “tribe_get_start_date($post->ID,false)” so that it only shows the date.
+ Added another table row for “Time:” and used this to output just the start and end times: “echo tribe_get_start_date($post->ID,true,’ ‘) . ” – ” . tribe_get_end_date($post->ID,true,’ ‘);”
—————
On single.php, I made similar changes. However, one thing of note was that the conditional was checking if tribe_get_start_date() equaled tribe_get_end_date(). This would only be true if we didn’t set an end time. But we want people to know how long the event is. So I replaced the conditional with what I have now in list.php, which is “tribe_is_multiday().”Modern Tribe folks, if you see anything amiss here or if you think we’ll run into issues, please let me know.
Thanks, CApril 18, 2013 at 9:48 am #46240chirocare
ParticipantSure. We must have been responding at the same time. Here’s a Gist. https://gist.github.com/relish27/5414230#file-list_and_single-php
Let me know what you think.April 18, 2013 at 10:10 am #46243Barry
MemberOK – as it happens Jonah (also on the support team) saw this thread and was about to jump in with an answer which I’ll relay to you now. His idea was to replace lines 51-65 in list.php with this code – does that help here?
April 18, 2013 at 11:33 am #46251chirocare
ParticipantWell, not exactly. When I output tribe_is_multiday() and tribe_get_all_day(), they both returned nothing (or not true). Therefore, I’d still get caught in your new conditional #2 — tribe_is_multiday() || !tribe_get_all_day() — which is what the first conditional was before. And, in your third conditional case (the “else”), which is where I want to end up, it still only shows the start time. I want it to show the date and the time range.
April 18, 2013 at 8:07 pm #46274Barry
MemberSure ok, so I’ve used the concept you posted initially as my template here:
Ideally, if the start and end date are the same, it could look like this:
——————
Date: May 11, 2013
Time: 8:00 am – 12:00 pm
——————And came up with this code which you could use to generate something close to the above. There are some cases it doesn’t work well with, such as a multiday event – consider an event starting today and ending in a couple of days, starting at 7pm and ending at 9am. It renders like this:
Date: April 18, 2013 – April 20, 2013
Time: 7.00pm – 9.00amHowever that might not be an issue in your case. I also stripped out some of the event schema markup, simply because I wasn’t 100% sure that this sort of configuration would work well with it, however you can test and adjust as needed.
April 21, 2013 at 8:20 am #46449chirocare
ParticipantThis reply is private.
April 23, 2013 at 8:39 am #46644Barry
MemberWell, I mean this is basically the realms of custom development so we can offer pointers but it’s ultimately up to you to build the solution you’re after here 🙂
Certainly if you prefer the way multiday events are handled in your own snippet then it makes sense to use that or, if you want a fusion of the two, then you’ll need to do a little more work on it.
I don’t think there’s too much more we can do here to help though so unless you’ve go further questions I’m inclined to close this ticket. Thanks!
April 23, 2013 at 8:52 am #46649chirocare
ParticipantYes, by all means — feel free to close it. Thanks for your help!
April 23, 2013 at 9:01 am #46651Barry
MemberGreat!
-
AuthorPosts
- The topic ‘Remove End Date if same as Start Date’ is closed to new replies.
