Blog Sections Open
Building Dependent Filters in Evolution CMS
Dependent filters are easiest to reason about when each selection narrows the available values for the next step instead of trying to solve everything in one giant query.
A three-step filter such as Region → District → Type of Leisure is a classic dependent-filter problem. The important part is not only the final search, but dynamically reducing the next selector based on the previous choice.
Desired behavior
- choose a region
- show only districts in that region
- then show only leisure types available in that district
Can autoFilter do this?
Some parts can be modeled around autoFilter, but once selectors depend on one another in sequence, many projects benefit from a dedicated helper or AJAX-driven filter source instead of one generic filter chain.
Recommendation
Think of dependent filters as a stateful UI problem. Keep the data relationships explicit, and let each selected value rebuild the options for the next field.
Counting Only Visible Children with ChildCounter
If a menu counter should ignore hidden resources, include the hidemenu condition in the document query instead of counting every child indiscriminately.
Using MODX API Functions from an External PHP File
If an external PHP script needs MODX or Evolution CMS functions, bootstrap the CMS first instead of trying to call API helpers in isolation.