From 8a9557a03328e648f0c6fca0bd24802c16f44b83 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 449b1497500..ef441fdeda1 100644 --- a/pages/index/IndexHandler.php +++ b/pages/index/IndexHandler.php @@ -60,6 +60,7 @@ public function index($args, $request) $this->setupTemplate($request); $router = $request->getRouter(); $templateMgr = TemplateManager::getManager($request); + $this->_setupAnnouncements($journal ?? $request->getSite(), $templateMgr); if ($journal) { // Assign header and content for home page $templateMgr->assign([ @@ -75,8 +76,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 1d9c1a15920..d2cbceef005 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"}