Display Cancelled Dates on Event Node with Smart Date Field

Created on 18 November 2024, about 1 month ago

Problem/Motivation

We are using Smart Date for our Event content types on a Drupal 10 site. Some of these events are classes that occur regularly but certain dates are cancelled. I understand how to cancel the dates using the Manage Instances button, but we would also like to display those cancelled dates on the full display of the event node. I could find no way through the UI to display the exceptions. As we are using Layout Builder on that content type, I then tried to make a custom block to display the exception dates, but still could not figure out how to access the overridden dates. Can you please advise how to achieve the display of excepted dates?

πŸ’¬ Support request
Status

Active

Version

4.1

Component

Smart Date Recur

Created by

πŸ‡ΊπŸ‡ΈUnited States virtualmitra

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @virtualmitra
  • πŸ‡ΊπŸ‡ΈUnited States virtualmitra

    I answered my own question. Instead of using:
    $insts = $rrule->getRuleInstances();
    to get the list of all active instances from which the canceled dates have already been purge, I needed to use:
    $insts = $rrule->makeRuleInstances();
    to get a fresh list of all possible instances. Thus, the list of canceled dates can be created with:

    $rrule = SmartDateRule::load($date_field_value['rrule']);
    $instances = $rrule->makeRuleInstances();
    $ovrds = $rrule->getRuleOverrides();
    foreach($ovrds as $ind => $ovrd) {
          $instance = $instances[$ind];
          $canceled_dates[] = $instance->getStart()->format('M j');
    }
    
Production build 0.71.5 2024