Add OnManagerSearch event to allow extending quick search#16915
Open
biz87 wants to merge 3 commits intomodxcms:3.xfrom
Open
Add OnManagerSearch event to allow extending quick search#16915biz87 wants to merge 3 commits intomodxcms:3.xfrom
biz87 wants to merge 3 commits intomodxcms:3.xfrom
Conversation
) Add a system event that fires during manager quick search processing, allowing plugins to register custom search providers via declarative configuration arrays. The processor builds and executes xPDO queries from these configs, supporting joins, custom icons/labels, and permission checks. No JS changes needed — the frontend already supports custom result types.
- Fix sortby with prefixed nameField (e.g. Product.name) - Add select() for main class when joins are used to prevent column conflicts - Validate xPDO class via getTableName() before querying - Add optional idField config key (default: id) for custom primary keys - Validate searchFields elements are non-empty strings
Ibochkarev
reviewed
Mar 5, 2026
Comment on lines
+323
to
+325
| 'name' => $record->get($nameField), | ||
| 'description' => !empty($descriptionField) ? $record->get($descriptionField) : '', | ||
| '_action' => $config['action'] . $record->get($idField), |
Collaborator
There was a problem hiding this comment.
Potential regression for prefixed fields (Alias.field).
This method now supports dotted nameField in sorting, but the result mapping still reads:
$record->get($nameField)$record->get($idField)
If config uses Product.name / Product.id, get() may not resolve these keys, which can produce empty name/id and broken _action URLs.
Please normalize field names before get() (strip alias), or select aliased columns and read those aliases.
Select dotted fields from joined tables and strip alias prefix before xPDO get() calls to correctly resolve values.
Ibochkarev
approved these changes
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #16912
Adds the
OnManagerSearchsystem event that fires during manager quick search (uberbar) processing. Plugins can register custom search providers through declarative configuration arrays — the processor builds and executes xPDO queries from these configs.Key changes:
OnManagerSearchevent (service=2, group=System) fired inSearch/Searchprocessor after built-in searchessearchProvider()method handles provider configs: builds xPDO queries with optional joins, custom search fields, permission checks, and custom icons/labelsArrayObjectis used for the$providersparameter so that object identity is preserved througharray_merge/extractin the event dispatch chain — all plugins share the same instancelabelandiconfields before falling back to built-in mappingsPlugin usage example:
Provider config keys:
classgetTableName)typenameFieldactiondescriptionFieldcontentFieldquick_search_in_content)labeliconpermissionidFieldid)joinsclass,alias,on,type)searchFieldsTest plan
OnManagerSearchthat registers a provider for an existing model (e.g.modCategory) and verify results appear in the search barpermissioncheck prevents results when user lacks the specified permissionlabelandicondisplay correctly in the search dropdownjoinsandsearchFieldsallow searching related model fieldsOnManagerSearchevent is created