WordPress.org

Ready to get started?Download WordPress

Forums

The Events Calendar
[resolved] tribe_is_multiday returning true, falsly (18 posts)

  1. Dave Navarro, Jr.
    Member
    Posted 1 year ago #

    Site: http://beta.wibwradio.com/

    The first event on the list is a single-day event from 7pm to 8pm on the same day, yet tribe_is_multiday() is returning true and the event date/time is displayed as:

    "February 6, 2013 7:00 pm – February 6, 2013 8:00 pm"

    I am trying to display the date/time as:

    "February 6, 2013; 7:00 pm – 8:00 pm"

    How can I compare the start date with the end date and not display the date twice if they are the same?

    http://wordpress.org/extend/plugins/the-events-calendar/

  2. Dave Navarro, Jr.
    Member
    Posted 1 year ago #

    I managed to figure it out.

  3. shadow772
    Member
    Posted 1 year ago #

    Could u please describe, how u did it?
    If other users have the same question.

  4. roblagatta
    Modern Tribe Support
    Plugin Author

    Posted 1 year ago #

    Thanks for confirming that you got this sorted, dnavarrojr! If you happen to review this thread and have a chance to share the solution, I'm sure shadow772 and others in a similar position would appreciate it.

  5. existonline
    Member
    Posted 1 year ago #

    dnavarrojr - please post up your solution! I'm trying to achieve the same result as shadow772 as well. I have been scouring the net for hours searching for a solution and have had no luck! :(

  6. Dave Navarro, Jr.
    Member
    Posted 1 year ago #

    I have to go back through the code to remember what I was doing. I'll do that in a couple of days when I'm back home. I'm out of town for work.

  7. existonline
    Member
    Posted 1 year ago #

    No worries, that would be great! Thanks so much :)

  8. Dave Navarro, Jr.
    Member
    Posted 1 year ago #

    I completely forgot that I backed up the site before I left and took a copy of the backup with me.

    In the file:

    views/events-list-load-widget-display.php

    I have the following:

    <li <?php echo $class ?>>
    	<div class="when">
    		<?php
    			$space = false;
    			$output = '';
          $s_dt = tribe_get_start_date( $post->ID, false );
          $e_dt = tribe_get_end_date( $post->ID, false );
    
          echo tribe_get_start_date( $post->ID ); 
    
          if( tribe_is_multiday( $post->ID ) || !$event->AllDay ) {
            if( $s_dt != $e_dt ) {
              echo ' – '. tribe_get_end_date($post->ID);
            } else {
              echo ' - '. str_replace( $e_dt . ' ', '', tribe_get_end_date( $post->ID));
            }
          }
    
          ?>
    	</div>
    	<div class="event">
    		<a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a>
    	</div>
    </li>

    I ended up comparing the start and end date and if they matched, I removed the end date from the output string.

  9. existonline
    Member
    Posted 1 year ago #

    You sir, are a legend! Thanks so much for this code dnavarrojr! I'm sure many other people will appreciate you sharing this as well :)

    Just another quick question (hopefully quick!)...

    I know that within the plugin's current capabilities in the WP admin area, it doesn't allow you to NOT SET an end date/time. So you can set a start date/time, but basically you're "forced" to set an end date/time - because in some instances you might just want to set a start date/time and NO end date/time.

    Do you have any ideas on how one would get past this?

    I had a thought - just for example - say you set the START date/time to "23 March 2013 6:00pm", then you set the SAME date/time for the END date/time - Do you think you would be able to write code that checks against this and "just doesn't apply an end date/time"?

    I hope that made sense! Thanks in advance for your help if you're able to help :)

  10. existonline
    Member
    Posted 1 year ago #

    No need to stress dnavarrojr, I've figured it out myself mate! It was pretty easy, once I actually looked at your code a bit further than the end of my nose! Haha! Here's what I did:

    <li <?php echo $class ?>>
    	<div class="when">
    		<?php
    			$space = false;
    			$output = '';
          			$s_dt = tribe_get_start_date( $post->ID, false );
          			$e_dt = tribe_get_end_date( $post->ID, false );
    
          			echo tribe_get_start_date( $post->ID ); 
    
          			if( tribe_is_multiday( $post->ID ) || !$event->AllDay ) {
    				if( $s_dt != $e_dt ) {
    					echo ' – '. tribe_get_end_date($post->ID);
    				} else if( $s_dt == $e_dt ) {
    					echo '';
    				} else {
    					echo ' - '. str_replace( $e_dt . ' ', '', tribe_get_end_date( $post->ID));
    				}
    		 	}
          		?>
    	</div>
    	<div class="event">
    		<a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a>
    	</div>
    </li>
  11. existonline
    Member
    Posted 1 year ago #

    Actually... No, that didn't work! Grrr! My bad! I'm gonna keep tinkering but I think I still need help with this one please :(

  12. existonline
    Member
    Posted 1 year ago #

    All done! I'm pretty darn sure that I got it correct this time! Hopefully this helps other people out there with the same problem :)

    <li <?php echo $class ?>>
    	<div class="when">
    		<?php
    			$space = false;
    			$output = '';
          			$s_dt = tribe_get_start_date( $post->ID, false );
    			$s_dt_time = tribe_get_start_date( null, false, 'g:ia' );
          			$e_dt = tribe_get_end_date( $post->ID, false );
    			$e_dt_time = tribe_get_end_date( null, false, 'g:ia' );
    
          			echo tribe_get_start_date( $post->ID ); 
    
          			if( tribe_is_multiday( $post->ID ) || !$event->AllDay ) {
    				if( $s_dt != $e_dt ) {
    					echo ' – '. tribe_get_end_date($post->ID);
    				} else if( $s_dt_time == $e_dt_time ) {
    					echo '';
    				} else {
    					echo ' - '. str_replace( $e_dt . ' ', '', tribe_get_end_date( $post->ID));
    				}
    		 	}
          		?>
    	</div>
    	<div class="event">
    		<a href="<?php echo get_permalink($post->ID); ?>"><?php echo $post->post_title; ?></a>
    	</div>
    </li>
  13. jonahcoyote
    Member
    Posted 1 year ago #

    Hi existonline, thanks for sharing your solution! Hopefully this helps others.

  14. existonline
    Member
    Posted 1 year ago #

    No worries jonahcoyote! I was just stoked to have figured that part out, but it wasn't all me - dnavarrojr was a big help also from the beginning of the topic :)

  15. jonahcoyote
    Member
    Posted 1 year ago #

    Awesome, thanks again! And thank you dnavarrojr!

  16. widecast
    Member
    Posted 7 months ago #

    existonline, thanks for the code snippet. Saved me a headache!

  17. existonline
    Member
    Posted 7 months ago #

    No worries widecast! It wasn't just me though, Dave Navarro, Jr helped :)

  18. widecast
    Member
    Posted 7 months ago #

    Thanks to Dave, too. :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.