From 41780874deb6e42ff536c4e6ef9a43c163421840 Mon Sep 17 00:00:00 2001 From: Nate Wright Date: Thu, 24 Aug 2023 11:46:42 +0100 Subject: [PATCH] pkp/pkp-lib#9253 Add site-level announcements --- pages/index/IndexHandler.php | 3 +- plugins/themes/default/styles/components.less | 3 +- templates/frontend/pages/indexSite.tpl | 31 +++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/pages/index/IndexHandler.php b/pages/index/IndexHandler.php index b106a98966b..8b3d1e817fd 100644 --- a/pages/index/IndexHandler.php +++ b/pages/index/IndexHandler.php @@ -64,6 +64,7 @@ public function index($args, $request) 'highlights' => $this->getHighlights($journal), ]); + $this->_setupAnnouncements($journal ?? $request->getSite(), $templateMgr); if ($journal) { // Assign header and content for home page $templateMgr->assign([ @@ -79,8 +80,6 @@ public function index($args, $request) IssueHandler::_setupIssueTemplate($request, $issue); } - $this->_setupAnnouncements($journal, $templateMgr); - $templateMgr->display('frontend/pages/indexJournal.tpl'); event(new UsageEvent(Application::ASSOC_TYPE_JOURNAL, $journal)); return; diff --git a/plugins/themes/default/styles/components.less b/plugins/themes/default/styles/components.less index 992a920aebd..f579ba4c904 100644 --- 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/templates/frontend/pages/indexSite.tpl b/templates/frontend/pages/indexSite.tpl index 261ee57982c..fd3ade85f05 100644 --- a/templates/frontend/pages/indexSite.tpl +++ b/templates/frontend/pages/indexSite.tpl @@ -18,6 +18,37 @@ {/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} +

{translate key="context.contexts"}