ModifyPluginViewEvent
\FGTCLB\ 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}
.
{jobs 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 | New | new |
{type,
{employment,
{data}
,
{record}
|
The extension name of the context is Academic.
What this extension passes in
| Method | Returns |
|---|---|
get | 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.. |
get | 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/ renders the link with
{privacy, see Add a field to the new job form.
<?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);
}
}
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
- Feature: The plugins dispatch the plugin view event
- Breaking: The view event of the new job form is gone: the event replaces the view event of the job form.
- Feature: The job list can be paginated: the variables of the pagination.