Skip to Content search facebook instagram pinterest twitter youtube

Customising the refine bar

The RefineBar class provides the functionality which lets an operator refine the list of records displayed on the contents view in the admin interface. It looks like this:

Refine bar

The fields displayed above are the defaults, but you can also add additional fields to refine by, using RefineWidgets. For example, if you had a 'type' column, you could provide a dropdown containing the valid types by using a RefineWidgetSelect. The RefineBar is set up by the constructor of the admin controller in question. For example:


    public function __construct()
        $types = Pdb::extractEnumArr($this->table_name, 'type');
        $widget = new RefineWidgetSelect('type', 'Type', $types);
        $this->refine_bar->addWidget($widget, '=');

The RefineWidgetAutocomplete and RefineWidgetTextbox classes can be used in a similar manner. When adding a widget, you can specify whether the value selected or entered must match the field value, be contained within the field, be found at the start of the field, etc. The operators available are those found in Pdb::buildClause, as follows:

Simple operators: = <= >= < > != <>

Operators for LIKE conditions; escaping of characters like % is handled automatically:
CONTAINS - generates a LIKE '%term%' condition
BEGINS - generates a LIKE 'term%' condition
ENDS -  generates a LIKE '%term' condition