From 63cb9c9eac55af8936007665c154741c008c73cf Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Thu, 2 Nov 2023 15:19:26 +0000 Subject: [PATCH] pkp/pkp-lib#9253 Add site-level announcements --- dbscripts/xml/upgrade.xml | 1 + pages/index/IndexHandler.php | 3 +- plugins/themes/default/styles/components.less | 3 +- .../styles/objects/announcement_summary.less | 8 +++++ .../default/styles/pages/indexServer.less | 1 + templates/frontend/pages/indexServer.tpl | 31 +------------------ templates/frontend/pages/indexSite.tpl | 2 ++ 7 files changed, 16 insertions(+), 33 deletions(-) diff --git a/dbscripts/xml/upgrade.xml b/dbscripts/xml/upgrade.xml index a1e4ef4407..05fe0962ce 100644 --- a/dbscripts/xml/upgrade.xml +++ b/dbscripts/xml/upgrade.xml @@ -110,6 +110,7 @@ + diff --git a/pages/index/IndexHandler.php b/pages/index/IndexHandler.php index 8fcfd97e07..8a29dc06d2 100644 --- a/pages/index/IndexHandler.php +++ b/pages/index/IndexHandler.php @@ -64,6 +64,7 @@ public function index($args, $request) 'highlights' => $this->getHighlights($server), ]); + $this->_setupAnnouncements($journal ?? $request->getSite(), $templateMgr); if ($server) { // OPS: sections $sections = Repo::section()->getCollector()->filterByContextIds([$server->getId()])->getMany(); @@ -96,8 +97,6 @@ public function index($args, $request) 'authorUserGroups' => Repo::userGroup()->getCollector()->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->filterByContextIds([$server->getId()])->getMany()->remember(), ]); - $this->_setupAnnouncements($server, $templateMgr); - $templateMgr->display('frontend/pages/indexServer.tpl'); event(new UsageEvent(Application::ASSOC_TYPE_SERVER, $server)); return; diff --git a/plugins/themes/default/styles/components.less b/plugins/themes/default/styles/components.less index f524d22533..11beb88a8f 100755 --- a/plugins/themes/default/styles/components.less +++ b/plugins/themes/default/styles/components.less @@ -392,7 +392,8 @@ } // Announcements -.cmp_announcements { +// Double class rule overrides .pkp_structure_main ul +.cmp_announcements.cmp_announcements { &:extend(.pkp_unstyled_list); margin-left: -@base; margin-right: -@base; diff --git a/plugins/themes/default/styles/objects/announcement_summary.less b/plugins/themes/default/styles/objects/announcement_summary.less index 86e7cbcb00..2e569a23bd 100755 --- a/plugins/themes/default/styles/objects/announcement_summary.less +++ b/plugins/themes/default/styles/objects/announcement_summary.less @@ -54,3 +54,11 @@ .cmp_button_text(@fa-var-chevron-right); } } + +@media (min-width: @screen-tablet) { + .obj_announcement_summary_has_image { + display: grid; + grid-template-columns: 33% auto; + gap: @triple; + } +} \ No newline at end of file diff --git a/plugins/themes/default/styles/pages/indexServer.less b/plugins/themes/default/styles/pages/indexServer.less index c18f9a8c58..3933eb0cbd 100755 --- a/plugins/themes/default/styles/pages/indexServer.less +++ b/plugins/themes/default/styles/pages/indexServer.less @@ -58,6 +58,7 @@ } > .obj_announcement_summary { + display: block; position: relative; padding: @triple @base; } diff --git a/templates/frontend/pages/indexServer.tpl b/templates/frontend/pages/indexServer.tpl index ed044eb001..63483bf8f1 100644 --- a/templates/frontend/pages/indexServer.tpl +++ b/templates/frontend/pages/indexServer.tpl @@ -55,36 +55,7 @@ {/if} - {* Announcements *} - {if $numAnnouncementsHomepage && $announcements|@count} -
- -

- {translate key="announcement.announcements"} -

- {foreach name=announcements from=$announcements item=announcement} - {if $smarty.foreach.announcements.iteration > $numAnnouncementsHomepage} - {break} - {/if} - {if $smarty.foreach.announcements.iteration == 1} - {include file="frontend/objects/announcement_summary.tpl" heading="h3"} -
- {else} - - {/if} - {/foreach} -
-
- {/if} + {include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage} {* Additional Homepage Content *} {if $additionalHomeContent} diff --git a/templates/frontend/pages/indexSite.tpl b/templates/frontend/pages/indexSite.tpl index e1d7ca8f36..848e62c458 100644 --- a/templates/frontend/pages/indexSite.tpl +++ b/templates/frontend/pages/indexSite.tpl @@ -22,6 +22,8 @@ {/if} + {include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage} +

{translate key="context.contexts"}