Skip to content

Commit

Permalink
pkp/pkp-lib#9253 Add site-level announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Aug 24, 2023
1 parent 20bd36c commit 8a9557a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pages/index/IndexHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion plugins/themes/default/styles/components.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions templates/frontend/pages/indexSite.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,37 @@
</div>
{/if}

{* Announcements *}
{if $numAnnouncementsHomepage && $announcements|@count}
<section class="cmp_announcements highlight_first">
<a id="homepageAnnouncements"></a>
<h2>
{translate key="announcement.announcements"}
</h2>
{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"}
<div class="more">
{else}
<article class="obj_announcement_summary">
<h4>
<a href="{url router=\PKP\core\PKPApplication::ROUTE_PAGE page="announcement" op="view" path=$announcement->getId()}">
{$announcement->getLocalizedTitle()|escape}
</a>
</h4>
<div class="date">
{$announcement->getDatePosted()|date_format:$dateFormatShort}
</div>
</article>
{/if}
{/foreach}
</div><!-- .more -->
</section>
{/if}

<div class="journals">
<h2>
{translate key="context.contexts"}
Expand Down

0 comments on commit 8a9557a

Please sign in to comment.