ModifyPluginViewEvent 

\FGTCLB\AcademicBase\Event\ModifyPluginViewEvent belongs to academic_base, and the plugins of seven academic extensions dispatch it when they render. A listener assigns further variables to the view, which the templates, partials and sections of the plugin then render. The event, its contract and an example are documented in the manual of academic_base. This page describes what the plugins of this extension pass in.

When it is dispatched 

Every plugin of this extension dispatches the event once each time an action renders its view, after the action assigned its own variables:

Plugin name Action Dispatched
List , ListAndDetail list after the profile query, the pagination and the letters
ListAndDetail , Detail detail after the page title was set
Card card after the query of the selected profiles
SelectedProfiles selectedProfiles after the query of the selection, and also while the selection is empty
SelectedContracts selectedContracts after the query of the selection, and also while the selection is empty

The filter form of the list posts to the action filter , which redirects to the list and renders nothing, so it dispatches no event. A detail view of a profile that does not exist answers with the page-not-found response before the event.

What this extension passes in 

getPluginControllerActionContext() returns the context the queries of the same rendering received: the extension name AcademicPersons , the plugin and action names above, the settings of the content element and the request. See The plugin action context. While a letter is selected, the setting paginationEnabled of that context is '0', because a letter switches the pagination off.

getView() holds the variables the action assigned:

Action Variables
list profiles, demand, activeListArguments, filterOptions, data, record, viewMode, viewModePartial, viewModes, defaultViewMode, plus paginator and pagination while the pagination is on, and alphabetFilterLetters while the letter navigation is on and no profiles are selected by hand
detail profile, publicProfile, data, record
card profiles, data, record
selectedProfiles profiles while profiles are selected, data, record, viewMode, viewModePartial, viewModes, defaultViewMode
selectedContracts contracts while contracts are selected, data, record, viewMode, viewModePartial, viewModes, defaultViewMode

Example 

A site links the detail view of every profile to a page with an appointment form. The page is a site setting of the site package, mySitepackage.appointmentPage, and the listener hands its uid to the detail templates as appointmentPageUid:

EXT:my_sitepackage/Classes/EventListener/AddAppointmentPage.php
<?php

declare(strict_types=1);

namespace MyVendor\MySitepackage\EventListener;

use FGTCLB\AcademicBase\Event\ModifyPluginViewEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;

final class AddAppointmentPage
{
    #[AsEventListener(identifier: 'my-sitepackage/add-appointment-page')]
    public function __invoke(ModifyPluginViewEvent $event): void
    {
        $context = $event->getPluginControllerActionContext();
        if ($context->getControllerExtensionName() !== 'AcademicPersons'
            || $context->getActionName() !== 'detail'
        ) {
            return;
        }
        $appointmentPage = (int)$context->getSite()?->getSettings()->get('mySitepackage.appointmentPage', 0);
        if ($appointmentPage > 0) {
            $event->getView()->assign('appointmentPageUid', $appointmentPage);
        }
    }
}
Copied!

A template override of the detail view renders the link with <f:link.page pageUid="{appointmentPageUid}"> .

Rules and pitfalls 

  • Check the extension name and the action name, or the plugin name. Every academic plugin dispatches the same event, and plugin names repeat between extensions.
  • A variable the listener assigns again replaces the one of the action in the view, and only there. The pagination, the letters of the letter navigation and the page title keep what the query returned. Replacing profiles of a paginated list changes nothing the visitor sees, because the template renders the items of paginator. Which profiles are shown belongs in ModifyProfileDemandEvent or ModifyProfileQueryEvent.
  • The event carries no profile data of its own. A listener reads the profile of the detail view from its view variable profile.

Introduced in