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 30, 2023
1 parent 4b1cd68 commit 738ab16
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 33 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($server, $templateMgr);
if ($server) {
// OPS: sections
$sections = Repo::section()->getCollector()->filterByContextIds([$server->getId()])->getMany();
Expand Down Expand Up @@ -92,8 +93,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;
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: 1 addition & 30 deletions templates/frontend/pages/indexServer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,36 +49,7 @@
</section>
{/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=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}
{include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage}

{* Additional Homepage Content *}
{if $additionalHomeContent}
Expand Down
2 changes: 2 additions & 0 deletions templates/frontend/pages/indexSite.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
</div>
{/if}

{include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage}

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

0 comments on commit 738ab16

Please sign in to comment.