Skip to content

Commit

Permalink
Merge pull request #589 from FitzwilliamMuseum/feature/add-customisab…
Browse files Browse the repository at this point in the history
…le-banner

Add editable banner to the top of the site
  • Loading branch information
AlanJIsaacson authored Jul 21, 2023
2 parents 856e053 + 5e2d40c commit 347f74a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
18 changes: 18 additions & 0 deletions app/Helpers/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Helpers;

use App\Models\AnnouncementGlobal;

class helpers {
/**
* Return the global announcement from the database
*
* @return array
*/
public static function getGlobalAnnouncement() {
$globalAnnouncment = AnnouncementGlobal::list();

return $globalAnnouncment;
}
}
30 changes: 30 additions & 0 deletions app/Models/AnnouncementGlobal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Models;

use App\DirectUs;

class AnnouncementGlobal extends Model
{
protected static string $table = 'announcement_global';

/**
* Return the announcement
*
* @returns array
*/
public static function list(): array
{
$api = new DirectUs(
self::$table,
array(
'fields' => '*.*.*.*',
'filter[status]' => 'published',
'meta' => '*',
'sort' => 'id'
)
);

return $api->getData();
}
}
2 changes: 2 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@
'View' => Illuminate\Support\Facades\View::class,
'Str' => Illuminate\Support\Str::class,
'Youtube' => Alaouy\Youtube\Facades\Youtube::class,

'SiteHelper' => App\Helpers\helpers::class,
],

];
22 changes: 22 additions & 0 deletions resources/views/includes/structure/nav.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,30 @@


<!-- Nav bars -->
{{-- If the client has a global announcement published in the CMS, then output it at the top of the page --}}
@if(
(!empty(SiteHelper::getGlobalAnnouncement()['data'][0]['status']) && SiteHelper::getGlobalAnnouncement()['data'][0]['status'] == 'published')
)
<nav class="navbar navbar-expand-lg navbar-dark bg-black fixed-top container-fluid" style="padding-top: 0; flex-direction: column;">
<div id="global-announcement" class="global-announcement" style="background: #EB0000; color: white; padding: 10px; text-align: center; width: 100%;">
<style>
#global-announcement a {
color: inherit;
text-decoration: underline;
}
</style>

{!! (SiteHelper::getGlobalAnnouncement()['data'][0]['announcement']) !!}
</div>
<div class="container-fluid" style="padding-top: 8px;">

@else

<nav class="navbar navbar-expand-lg navbar-dark bg-black fixed-top">
<div class="container-fluid">

@endif

<a class="navbar-brand" href="{{ route('home') }}">
<img src="{{asset("/images/logos/FitzLogo.svg")}}"
alt="The Fitzwilliam Museum Logo"
Expand Down

0 comments on commit 347f74a

Please sign in to comment.