Skip to content

Commit

Permalink
v1.0.6 adds ability to show snow day banner after/before specific dates
Browse files Browse the repository at this point in the history
  • Loading branch information
joebuonocore committed Nov 10, 2023
1 parent ee13596 commit 3f1c91d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions components/Snowday.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
29 changes: 29 additions & 0 deletions models/settings/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3f1c91d

Please sign in to comment.