Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

New releases for code and query field plugins have just landed! Some great new features, general code cleanup and improvements, and more! Check out the details below.

First up is both Query and Code fields have been improved further to support content plugins. This will allow you to pre-parse your query or code with content plugin functionality. This is especially handy if you want to grab CB Paid Subscriptions information before running your query or code.

Both plugins also gained support for their select type fields (single, multiple, radio, checkbox) to customize the resulting options on profile with custom HTML and substitutions. Below is what this new parameter looks like for query select types for example.

Now when viewing profile the fields option will display bold due to the strong HTML tag. This gives you a lot more creative freedom over how your field options display.

The biggest feature now available however is the ability to filter Query Select and Query Multi-Select. This lets your users search the dropdown and filter the query dynamically! This is critical if you have a very large dropdown (e.g. 1000 options!) to keep things performant and usable. You'll first need to toggle this on with the new parameter shown below.

Next you'll need to be sure your query takes into account the filter. It can do so by using the [filter] substitution, but we'll get to that in a minute. For now lets take a look at how this displays.

Notice the search input now available will let them search the input, which will call your query with their search and allow you to filter the results down.

This leads into the next new feature for query select type fields. Multi-query. It's now possible to supply more than 1 query to combine the results into a single set of options. This is great for when you need to build a select from multiple database tables without having to do joins that may not be relevant to each other causing performance problems. So for example the following is now possible.

Query:

SELECT * FROM `#__select_list1` LIMIT 5;
SELECT * FROM `#__select_list2` LIMIT 5;

This would pull 5 options from 2 different database tables and combine their results. Duplicates are automatically handled for you based off the option value.

Now lets get back to filtering. Since your query needs to take into account the user supplied filter it also needs to take into account their already selected value. This allows it to validate on user store properly and prevent overloading your site by querying for unnecessary options. You have a couple of ways you can do this and I'll explain them all below!

Simple:

SELECT * FROM `#__select_list` WHERE ( `label` LIKE '%[filter]%' OR `value` = '[value]' )

This simple example will only output options if they match a searched filter against their display label OR if the existing stored value matches. This works fine for most simple cases, but we can do better now with multi-query.

Multi-Query:

SELECT * FROM `#__select_list` WHERE `value` = '[value]';
SELECT * FROM `#__select_list` WHERE `label` LIKE '%[filter]%' LIMIT 5;

Now we can ensure we validate AND we only return a limited set of filtered options. However this supports substitutions so lets go 1 more step further for a more robust solution.

Multi-Query Substitutions:

[cb:if value!=""]SELECT * FROM `#__select_list` WHERE `value` = '[value]';[/cb:if]
[cb:if filter!=""]SELECT * FROM `#__select_list` WHERE `label` LIKE '%[filter]%' LIMIT 5;[/cb:if]
[cb:if value="" and filter=""]SELECT * FROM `#__select_list` LIMIT 5;[/cb:if]

Now we only query for the existing value if we have an existing value. We only query for a filter if there is a filter. Finally if there is no value or filter we just grab 5 options. You can use all the power that substitutions have to offer here to create the query you need.

For a full list of changes take a look at our forge below.

CB Code Field - Changelog

CB Query Field - Changelog