diff --git a/ReadMe.md b/ReadMe.md index 70c5be5..46a45da 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -23,6 +23,7 @@ You'll need to add the component 'Snow Day Banner' to your theme. It is recommen ## ⚙️ Explanation of settings * Enable the Snow Day Banner's visibility +* Set the Snow Day Banner to display after and/or before specific dates * Manage the content of the banner (supports raw HTML; it's recommended to keep the banner simple) * Set whether the banner can be hidden * Add any custom CSS diff --git a/components/Snowday.php b/components/Snowday.php index c0d3011..b85419f 100644 --- a/components/Snowday.php +++ b/components/Snowday.php @@ -33,6 +33,26 @@ public function message() public function enabled() { if($settings = Settings::get('show_showday')){ + + if(Settings::get('show_before_after', false)){ + + $start_date = date('Y-m-d', strtotime(Settings::get('date_start'))); + $end_date = date('Y-m-d', strtotime(Settings::get('date_end'))); + $current_date = date('Y-m-d'); + + trace_log($start_date); + trace_log($end_date); + trace_log($current_date); + + if(($current_date >= $start_date || $start_date == '1970-01-01') && ($current_date <= $end_date || $end_date == '1970-01-01')){ + return true; + } + else { + return false; + } + + } + return true; } diff --git a/models/settings/fields.yaml b/models/settings/fields.yaml index 1c72181..0b2ef21 100644 --- a/models/settings/fields.yaml +++ b/models/settings/fields.yaml @@ -11,6 +11,35 @@ fields: label: Show message comment: When checked, a banner will be displayed at the top of the website type: checkbox + show_before_after: + label: Show between two dates + comment: When checked, a banner will only be displayed if the current date is between those provided + type: checkbox + cssClass: field-indent + trigger: + field: show_showday + condition: checked + action: show + date_start: + label: Start date + type: datepicker + mode: date + span: auto + cssClass: field-indent + trigger: + field: show_before_after + condition: checked + action: show + date_end: + label: End date + type: datepicker + mode: date + span: auto + cssClass: field-indent + trigger: + field: show_before_after + condition: checked + action: show snowday_message: label: Message content commentAbove: This message will be shown at the top of the website in the snow day banner diff --git a/updates/version.yaml b/updates/version.yaml index f111dd6..115fd4f 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -3,3 +3,4 @@ 1.0.3: Third version of Snow Day 1.0.4: Fourth version of Snow Day 1.0.5: Fifth version of Snow Day +1.0.6: Sixth version of Snow Day