-
Notifications
You must be signed in to change notification settings - Fork 234
Filters
Filters modify data in a column after running a report, but before displaying it.
All Filter classes extend FilterBase and pre-defined filters are located in classes/filters/. User defined filters can be placed in classes/local/.
See how to Create a Custom Report Filter
Filters are applied with the FILTER header as follows:
FILTER: {
"filter": "geoip",
"column": 1,
"params": {}
}
For the 1st column in every row, the following will be called.
$value = geoipFilter::filter($value, $params);
A column can have more than 1 filter and they will be applied in the order they appear in the headers.
This marks a column as containing html data. Normally all report data is escaped before outputting. This filter turns off escaping.
This filter has no parameters.
FILTER: {
"filter": "html",
"column": "My Data"
}
If a column contains:
<strong>Data</strong>
It would normally be output as:
<strong>Data</strong>
After the htmlFilter is applied, it will output in it's original format and you will be able to see the bold text.
This wraps a column's contents in pre tags. It is useful if you want to preserve white space in a column.
This filter has no parameters.
FILTER: {
"filter": "pre",
"column": 2
}
This removes a column from a report. This is useful if you want to use some columns just as a source of data for charts.
This filter has no parameters.
FILTER: {
"filter": "hide",
"column": 3
}
This converts ip addresses into human readable locations. It requires the geoip php extension to work.
This filter has no parameters.
FILTER: {
"filter": "geoip",
"column": "ip"
}
This will convert:
173.194.33.3
Into:
Mountain View, CA
Add a css class to the column.
FILTER: {
"filter": "class",
"column": 1,
"params": {
"class": "right"
}
}
There are a couple of pre-defined css classes that are useful, but feel free to add your own to the template.
- right (right aligned)
- center (center justified)
Turns a numeric column into a horizontal bar chart. All bars will be scaled to the highest value in the column.
FILTER: {
"filter": "bar",
"column": 2,
"params": {
"width": 300
}
}
The 'width' parameter specified the maximum bar width in pixels. It defaults to 200px.
Turns a column into a link. The value of the column is used as the href.
FILTER: {
"filter": "link",
"column": 1,
"params": {
"display": "View",
"blank": true
}
}
This will turn the following:
http://localhost/product/view/1/
Into:
<a href="http://localhost/product/view/1/" target="_blank">View</a>
By default, the 'display' parameter is set to the href value.
The 'blank' parameter, if set to true, will open the link in a new window. The default is false.