ModifyPluginViewEvent 

\FGTCLB\AcademicBase\Event\ModifyPluginViewEvent is owned by academic_base, which describes it for the seven academic extensions whose plugins dispatch it in its developer chapter. This page says what the plugins of academic_jobs hand to it.

When it is dispatched 

Each of the three content elements dispatches the event once each time it renders, after its action assigned its own variables. Submitting the form renders nothing and dispatches no view event, the AfterSaveJobEvent serves it.

Content element Plugin name Action Variables assigned before the event
Job List List list {jobs} , {data} , {record} , and while the pagination is enabled {paginator} and {pagination} . {jobsWithHiddenDefaultRecord} maps the uid of every listed job whose record in the default language is hidden to true.
Job Details Detail show {job} , {data} , {record}
Job Form NewJobForm new {typeOptions} , {employmentTypeOptions} , {data} , {record}

The extension name of the context is AcademicJobs.

What this extension passes in 

Method Returns
getPluginControllerActionContext() The context of the rendering plugin: the request, the site and its language, the content object, the plugin and action name and the settings of the plugin, the options of the content element over the TypoScript of plugin.tx_academicjobs.settings .
getView() The view the action renders. A variable a listener assigns to it reaches the template and its partials.

Example: a privacy page next to the job form 

A site links its privacy statement above the submit button of the job form. The page differs per site, so the site package declares a site setting for it, and a listener hands the page to the form. A template override of Job/Forms/AdditionalFields.html renders the link with {privacyPageId} , see Add a field to the new job form.

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

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

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

final class AddPrivacyPageToJobForm
{
    #[AsEventListener(identifier: 'my-extension/add-privacy-page-to-job-form')]
    public function __invoke(ModifyPluginViewEvent $event): void
    {
        $context = $event->getPluginControllerActionContext();
        if ($context->getControllerExtensionName() !== 'AcademicJobs'
            || $context->getPluginName() !== 'NewJobForm'
        ) {
            return;
        }
        $privacyPageId = (int)($context->getSite()?->getSettings()->get('mySitepackage.privacyPageId') ?? 0);
        $event->getView()->assign('privacyPageId', $privacyPageId);
    }
}
Copied!

Rules and pitfalls 

The validations of the form cannot be replaced. The job form assigns {validations} after the event on purpose, so the required marks of the form always match what the validation checks.

Replacing the jobs of a paginated list changes nothing. The paginator is built from the jobs before the event, and a paginated list renders the page of the paginator. Without the pagination, the list renders {jobs} , and a listener that replaces it changes what is listed. Which jobs a list shows is better decided by its options.

The detail page is cached. The listener runs when the page is rendered for the cache, not for every visitor. The job list and the job form are not cached and run it on every request.

Introduced in