Automatically populating items from the database

Including the db_items property on a panel lets you populate the panel's items array with items from the database.

Server side pagination and sorting will also be applied, though there are options to turn this off and send all of the rows.

Specifying a Table

You need to specify a table and an id_column. Optionally you can include a where_statement. Then the CMS populate your items with rows from the table that you specified.

The query will be GROUP BYed your id_column.

You should always make a table alias for any table you include, and should always include it in your column names.


You can add columns to your SQL query by including the db_column property for a column.

Your id_column and your db_columns can be SQL statements/functions. For example, you may wish to form an id with the CONCAT() function.

You can use COUNT() and other group functions as columns, but you should never use COUNT(*) as this will not work if another Plugin Developer adds another table join. Instead you should use a statement like COUNT(DISTINCT t.column_name) to account for any potential duplicates caused by a table join.

Reference for db_items: