ModifyPluginViewEvent
\FGTCLB\ 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
,
List |
list
| after the profile query, the pagination and the letters |
List,
Detail
|
detail
| after the page title was set |
Card
|
card
| after the query of the selected profiles |
Selected |
selected | after the query of the selection, and also while the selection is empty |
Selected |
selected | 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
get returns the context the queries of
the same rendering received: the extension name
Academic, 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 pagination of that context is '0', because
a letter switches the pagination off.
get holds the variables the action assigned:
| Action | Variables |
|---|---|
list
| profiles, demand, active, filter,
data, record, view, view, view,
default, plus paginator and pagination while the
pagination is on, and alphabet while the letter
navigation is on and no profiles are selected by hand |
detail
| profile, public, data, record |
card
| profiles, data, record |
selected | profiles while profiles are selected, data, record,
view, view, view, default |
selected | contracts while contracts are selected, data, record,
view, view, view, default |
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,
my, and the listener hands its uid to the
detail templates as appointment:
<?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);
}
}
}
A template override of the detail view renders the link with
<f:.
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
profilesof a paginated list changes nothing the visitor sees, because the template renders the items ofpaginator. 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
- Feature: The plugins dispatch the plugin view event made the plugins of this extension dispatch the event.
- Breaking: The list, detail and selection events of the plugins are gone replaced the list, detail, selected profiles and selected contracts events with it.
- Important: The profile queries see a letter switching off the pagination hands it the context the queries receive.