Skip to content

Commit e319301

Browse files
Added hide event option
Added option to hide Events. Next to all event notifications, an "X" will now be displays, which hides the notification if clicked until a new event notification is shown. This works by setting a cookie with the ID of the event notification. Learn more about this on the Blog post here: https://blog.littlelink-custom.com/hide-event-option/
1 parent 29d5c7d commit e319301

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

resources/views/layouts/sidebar.blade.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,26 @@ function URL_event_exists(string $url): bool
197197
<?php
198198
$GetEventJson = file_get_contents("https://julianprieber.github.io/littlelink-custom-events/event.json");
199199
$EventJson = json_decode($GetEventJson, true);
200+
if(isset($_COOKIE['HideEvent']) == NULL) {
201+
setcookie("HideEvent",$_COOKIE['ID'] = "0", time()+60*60*24*5, "/");
202+
header('Location: ' . url('/panel/index'));
203+
exit();
204+
}
200205
?>
201206
@if(auth()->user()->role == 'admin' and strtotime(date("d-m-Y")) < strtotime($EventJson['enddate']))
207+
@if(isset($_COOKIE['HideEvent']) and $_COOKIE['HideEvent'] != $EventJson['id'])
202208
<nav class="navbar navbar-expand-lg navbar-light bg-light">
203209
<div class="container-fluid">
204-
<a class="nav-link" href="{{ $EventJson['link'] }}" target="{{ $EventJson['target'] }}"><mark onMouseOver="{{ $EventJson['hoveron'] }}" onMouseOut="{{ $EventJson['hoveroff'] }}" style="{{ $EventJson['style'] }}" title="{{ $EventJson['hover'] }}">{{ $EventJson['title'] }}</mark></a>
210+
211+
212+
<a class="nav-link" href="{{ $EventJson['link'] }}" target="{{ $EventJson['target'] }}"><mark onMouseOver="{{ $EventJson['hoveron'] }}" onMouseOut="{{ $EventJson['hoveroff'] }}" style="{{ $EventJson['style'] }}" title="{{ $EventJson['hover'] }}">{{ $EventJson['title'] }}</mark></a> <a href="?hide_event" title="Click to hide this message">❌</a>
213+
<?php
214+
if (strpos($_SERVER['REQUEST_URI'], "hide_event") !== false){
215+
setcookie("HideEvent",$_COOKIE['ID'] = $EventJson['id'], time()+60*60*24*5, "/");
216+
header('Location: ' . url('/panel/index'));
217+
exit();
218+
}
219+
?>
205220
</div>
206221
</nav>
207222
@endif
@@ -215,6 +230,7 @@ function URL_event_exists(string $url): bool
215230
}
216231
</script>
217232
@endif
233+
@endif
218234
<! –– #### end event detection #### ––>
219235
@yield('content')
220236
@@ -226,4 +242,4 @@ function URL_event_exists(string $url): bool
226242
<script src="{{ asset('/studio/js/bootstrap.min.js') }}"></script>
227243
<script src="{{ asset('/studio/js/main-dashboard.js') }}"></script>
228244
</body>
229-
</html>
245+
</html>

0 commit comments

Comments
 (0)