• Resolved ensemblebd

    (@ensemblebd)


    Hello, I decided to modify your plugin, because when it lists multi-day events from the feed, it basically shows only one date, the start or end date.
    And even if you use the start-custom with an offset, there is NO way within shortcode syntax to provide an index by which to multiply by days , since the loop counter isn’t exposed.

    Therefore here is the code to permit it to properly list the day, when multiple days listing is enabled for multi-day events.

    Shortcode syntax for post:
    [if-multi-day] [start-custom format="M d, Y" offset="day_diff"] [/if-multi-day]
    cool that’s easy right.

    So here’s the patched code:
    includes/class-gce-feed.php Line #26, now is…
    $feed_end,$multi_day_map=array();

    good stuff. Ok now the final mod:
    includes/class-gce-event.php
    line #295: if ($offset!=’day_diff’) $offset = intval( $offset );
    And here’s the whole block for start-custom shortcode:

    case 'start-custom':
    				if ($offset=='day_diff') {
    					$length=$this->gce_human_time_diff( $this->start_time, $this->end_time, $precision );
    					$index=0;
    					if (isset($this->feed->multi_day_map[$this->title])) {
    						$index=$this->feed->multi_day_map[$this->title];
    						if ($index >= $length) $index=0; // in case object persists across page load
    						else {
    							$this->feed->multi_day_map[$this->title]++;
    							$index=$this->feed->multi_day_map[$this->title];
    						}
    					} else {
    						$this->feed->multi_day_map[$this->title]=0;
    					}
    					$offset=(86400 * $index) +1;
    
    					return $m[1].date_i18n($format,$this->start_time+$offset).$m[6];
    				} else {
    					return $m[1] . date_i18n( $format, $this->start_time + $offset ) . $m[6];
    				}

    Now it displays the correct date for each event. Good day to you.

    https://ww.wp.xz.cn/plugins/google-calendar-events/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Nick Young

    (@nickyoung87)

    Can you post a screenshot or an example of what this does? I am not sure I follow what the original problem was and maybe if there was another way to do it from within the plugin or if it was just the way the plugin is currently designed to handle a certain situation.

    Thanks!

    I’m also encountering this issue. The problem occurs when you have a multi-day event (say, March 20 through March 22) in your calendar and are displaying events as a list. With a format like [start-date]: [event-title], they show up like

    – Feb 11: A previous event
    – Mar 20: Multi-Day Event
    – Mar 20: Multi-Day Event
    – Mar 20: Multi-Day Event
    – Apr 17: A subsequent event

    It would be much preferable to have the events show as

    – Feb 11: A previous event
    – Mar 20: Multi-Day Event
    – Mar 21: Multi-Day Event
    – Mar 22: Multi-Day Event
    – Apr 17: A subsequent event

    with each multi-day event entry with the date of that day. Now, I understand that this occurs because I am using the [start-date] shortcode, which always gives the first day of the event, but I don’t see what else I should use. Perhaps there should be a new [current-date] shortcode added?

    Alternatively, perhaps the event shouldn’t be displayed repeatedly for each day, but instead show a range when the event spans multiple days.

    The specific widget settings I’m actually using are

    Display Events as: List
    Sort Order: Ascending
    Events Per Page: Number of Events, 7
    Display Start Date Offset: Number of Days Back, 1

    Here’s a proof of concept patch that adds the [current-date] shortcode I was thinking of:

    --- a/includes/class-gce-event.php
    +++ b/includes/class-gce-event.php
    @@ -94,3 +94,3 @@
             */
    -       function get_event_markup( $display_type, $num_in_day, $num ) {
    +       function get_event_markup( $display_type, $num_in_day, $num, $current_day_time ) {
                    //Set the display type (either tooltip or list)
    @@ -104,2 +104,5 @@
    
    +               //Set the time of the start of the current event day
    +               $this->current_day_time = $current_day_time;
    +
                    $this->time_now = current_time( 'timestamp' );
    @@ -220,2 +223,3 @@
                            'start-date',     //The start date of the event (uses the date format from the feed options, if it is set. Otherwise uses the default WordPress date format)
    +                       'current-date',
                            'start-custom',   //The start time / date of the event (uses a custom PHP date format, specified in the 'format' attribute)
    @@ -316,2 +320,5 @@
    
    +                       case 'current-date':
    +                               return $m[1] . date_i18n( $this->feed->date_format, $this->current_day_time + $offset ) . $m[6];
    +
                            case 'start-custom':
    --- a/includes/class-gce-display.php
    +++ b/includes/class-gce-display.php
    @@ -368,3 +368,3 @@
                                                //Add the event markup
    -                                           $event->get_event_markup( 'list', $num_in_day, $i ) .
    +                                           $event->get_event_markup( 'list', $num_in_day, $i, $key ) .
                                                '</div>';
    Thread Starter ensemblebd

    (@ensemblebd)

    This looks good, I’ll try it out on my customer’s site as well; it’s highly preferable to the one I coded.

    And recommend it to be merged into future update of this plugin, assuming it works as prescribed! 🙂

    Plugin Contributor Nick Young

    (@nickyoung87)

    Ok so the problem is that the initial date stays the same?

    So like

    10th – event
    10th – event
    10th – event

    instead of

    10 ..
    11 …
    12 …

    (I know this is pretty much the same thing you said above but I just want to confirm I am getting this correctly)

    Yes, exactly.

    Plugin Contributor Nick Young

    (@nickyoung87)

    Do any of the latest updates help out with this at all?

    Plugin Contributor Nick Young

    (@nickyoung87)

    Assuming this is resolved since there have not been any recent replies here. Let me know if there is anything else I can help with.

    Thanks!

    Sorry – I know thread is marked resolved, but I experience this issue: date for multi-day events all display as either the start-date or end-date.

    I did try to modify the plugin using the information provided by the OP, but didn’t get it to work, and frankly would rather not modify the plugin anyway.

    Is there something I’m missing, or does the plugin not handle multi-day event dates natively?

    Thanks everybody. I were in the same problem and I finally resolved completely.

    Following ensemblebd instructions, the problem is that the one day events doesn´t appears.

    The solution is to write this shortcode syntax for post:
    [if-single-day]
    [start-date]
    [/if-single-day]
    [if-multi-day]
    [start-custom format=”l , d F” offset=”day_diff”]
    [/if-multi-day]

    And then you can follow ensemblebd instructions and everything works fine.

    Good luck!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Multi-Day Events showing same date’ is closed to new replies.