Skip to content
  1. Extras
  2. Localizator3
  3. Events

Events ​

Resource localizations ​

EventWhenParameters
OnBeforeSaveLocalizationBefore create and updatemode, id, data, localizatorContent (object), object
OnSaveLocalizationAfter create and updatemode (new / upd), id, localizatorContent (object), object.
No data or objectType keys.
OnBeforeRemoveLocalizationBefore removeid, localizatorContent, object
OnRemoveLocalizationAfter removeid, localizatorContent, object
OnLocalizatorContentDuplicateAfter a localization is duplicatedmode (duplicate), id, resource_id, source_key, key.
Not registered in _build/elements/events.php.

Languages ​

EventWhenParameters
OnBeforeSaveLocalizatorLanguageBefore create and updatemode, id, data, localizatorLanguage (object), object
OnSaveLocalizatorLanguageAfter create and updatemode (new / upd), id, localizatorLanguage (object), object.
No data or objectType keys.

Language and resource resolution ​

EventWhenParameters
OnBeforeFindLocalizationBefore language lookup by host and URLlanguage, http_host, request.
A non-empty string from the plugin aborts the lookup.
return false does not stop it.
Nothing is printed to the page.
OnFindLocalizationAfter a lookup attempt, including when no language was foundlanguage, http_host, request.
Not fired when OnBeforeFindLocalization aborted or on auto-detect 302 redirect.
OnToggleLocalizatorLanguageAfter the current language is appliedlanguage, language_key, http_host, request.
On a full page and via the connector (Referer) it fires for every found language.
Skip when key and cultureKey are unchanged only for a repeated set via the language parameter or cookie.
OnFindLocalizatorResourceWhen resolving a resourceresource (starts false), request.
If the plugin set resource, the built-in findResource() is not called.
OnHasLocalizatorError404Before a 404 when localization is missingresource, language_key.
Only when localizator3_404_if_no_localization is on, the language key is non-empty, and fields are not taken from the base-language resource.

Внимание

Return false from an OnHasLocalizatorError404 handler to skip the error page. The core may still log that the plugin failed.

Localization form ​

EventWhenParameters
OnBuildLocalizationTabsBuilding form tabsDepends on the calling processor

Active path: mgr/content/getformconfig ​

  • localizatorContent — always null.
  • tabs — by reference.
  • resource, user.
  • customization — by reference, keys user_id, resource_id, context_key, class_key.

You can add fields via tabs and customization if the change lands in $modx->event->returnedValues and the plugin output is empty.

Legacy processor: mgr/fields ​

  • localizatorContent — by reference.
  • tabs, customization — not by reference.
  • customization — only user_id, resource_id.

After the event, the form reads only tabs via $modx->event->returnedValues['tabs'] when plugin output is empty. customization is not applied to the form.

A plugin can add a tab with a custom field:

php
<?php
if ($modx->event->name !== 'OnBuildLocalizationTabs') {
    return;
}

$tabs = $modx->event->params['tabs'] ?? [];
$tabs['mine'] = [
    'id' => 'mine',
    'caption' => 'My fields',
    'fields' => ['myfield'],
];
$modx->event->returnedValues['tabs'] = $tabs;

The plugin must print nothing: the form uses $modx->event->returnedValues['tabs'] only when its output is empty.