Add announcement quick actions to Community Navigator block

Submitted by admin on
Status
Priority
Medium

Add "Add Announcement" and "Manage Announcements" quick actions to CommunityNavigatorBlock::buildQuickActions(), then apply the rsvp_announcement recipe on local and live.

Code change

File: rsvp-system-module/modules/rsvp_community_navigator/src/Plugin/Block/CommunityNavigatorBlock.php

In buildQuickActions(), add inside a node-type existence guard so the navigator stays safe if the recipe hasn't been applied:

if (\Drupal::service('entity_type.manager')->getStorage('node_type')->load('announcement')) { $actions['add_announcement'] = [ 'label' => $this->t('Add Announcement'), 'url' => '/node/add/announcement?community=' . $communityTid . '&date=' . $currentYm, 'min_access_level' => UserContext::LEVEL_EDITOR, 'page_context' => ['any'], 'weight' => 1, ]; $actions['manage_announcements'] = [ 'label' => $this->t('Manage Announcements'), 'url' => '/admin/content?type=announcement&community=' . $communityTid, 'min_access_level' => UserContext::LEVEL_COORDINATOR, 'page_context' => ['any'], 'weight' => 17, ]; }

Weights: add_event=0, add_announcement=1, add_event_series=2, reserve_space=5, reservation_queue=10, manage_spaces=15, manage_announcements=17, moderation_queue=20

Apply recipe (local then live)

Local: ddev exec drush recipe /var/www/html/web/recipes/contrib/rsvp-recipes/recipes/rsvp_announcement && ddev drush cr
Live: ssh [email protected] "cd /opt/www/rsvp-system.org && vendor/bin/drush recipe .../rsvp_announcement && vendor/bin/drush cr"

Verification

  • Create test announcement: set field_community_owner + field_announcement_date_range spanning today
  • Community section page shows announcement above content
  • Calendar month page shows same announcement for that month
  • Editor sees "Add Announcement" in navigator; coordinator sees "Manage Announcements"