ModifyPluginViewEvent 

\FGTCLB\AcademicBase\Event\ModifyPluginViewEvent belongs to academic_base, and the plugins of seven academic extensions dispatch it. It hands a listener the view of a plugin once the plugin has assigned its own variables, so a listener adds a variable to the templates without replacing the controller. The event itself, and the rules that apply to every plugin, are described on its page in the manual of academic_base. This page describes what the content elements of academic_partners pass in.

When it is dispatched 

All four content elements dispatch it once each time they render, as the last step of their action:

Content element Plugin name Action Dispatched after
Partner List List list ModifyPartnerListEvent and the pagination
Partner Map Map map ModifyPartnerListEvent
Partners Linked PartnershipsList partnershipsList reading the partnerships of the page
Partner Logo Teaser PartnershipsTeaser partnershipsTeaser reading the partnerships of the page

What this extension passes in 

Method Returns
getPluginControllerActionContext() The context of the content element: the extension name AcademicPartners , the plugin and action name of the table above, the request, the site and its language, the content object and the settings of the content element, its FlexForm merged over plugin.tx_academicpartners.settings .
getView() The view, with the variables the action assigned.

The variables a listener finds in the view:

Content element Variables
Partner List {partners} , {categories} , {demand} , {filterTypes} , {visitorSelection} , {data} , {record} , and with the pagination enabled {paginator} , {pagination} and {demandArguments}
Partner Map the same, without the pagination
Partners Linked, Partner Logo Teaser {partnerships} , {partnershipRoles} , {partnershipsWithoutRole} , {data} , {record}

Example 

A site shows a link to its page of all partners below the logo teaser of a project page. The uid of that page is a site setting of the site package, and a listener hands it to the template of the teaser:

EXT:my_extension/Classes/EventListener/AddAllPartnersPageToTheTeaser.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

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

final class AddAllPartnersPageToTheTeaser
{
    #[AsEventListener(identifier: 'my-extension/add-all-partners-page-to-the-teaser')]
    public function __invoke(ModifyPluginViewEvent $event): void
    {
        $context = $event->getPluginControllerActionContext();
        if ($context->getControllerExtensionName() !== 'AcademicPartners'
            || $context->getPluginName() !== 'PartnershipsTeaser'
        ) {
            return;
        }
        $pageUid = (int)($context->getSite()?->getSettings()->get('myExtension.allPartnersPage') ?? 0);
        if ($pageUid > 0) {
            $event->getView()->assign('allPartnersPage', $pageUid);
        }
    }
}
Copied!

An override of Templates/Partner/PartnershipsTeaser.html renders the link with <f:link.page pageUid="{allPartnersPage}"> .

Rules and pitfalls 

Check the extension name and the plugin name. One listener receives the event of every academic plugin that dispatches it. List is the plugin name of the partner list and of plugins of other academic extensions, so the extension name tells them apart.

A replaced variable is replaced in the view only. A listener that assigns {partners} again changes what the template renders, not the pagination, which was built from the partners before, nor the categories of the filter. A change of which partners are shown belongs in ModifyPartnerListEvent.

The partnership content elements are cached. Partners Linked and Partner Logo Teaser are rendered when the page is rendered, and the page is cached with what the listener assigned, so a listener cannot assign something different for different visitors there. The partner list and the map are not cached, a listener runs on every request that renders them.

Introduced in