Piwik\DataTable\Filter\

ColumnDelete

Filter that will remove columns from a DataTable using either a blacklist, allowlist or both.

This filter is used to handle the hideColumn and showColumn query parameters.

Basic usage example

$columnsToRemove = array('nb_hits', 'nb_pageviews');
$dataTable->filter('ColumnDelete', array($columnsToRemove));

$columnsToKeep = array('nb_visits');
$dataTable->filter('ColumnDelete', array(array(), $columnsToKeep));

Constants

This class defines the following constants:

  • APPEND_TO_COLUMN_NAME_TO_KEEP — Hack: when specifying "showColumns", sometimes we'd like to also keep columns that "look" like a given column, without manually specifying all these columns (which may not be possible if column names are generated dynamically) Inherited from ColumnDelete

APPEND_TO_COLUMN_NAME_TO_KEEP

Column will be kept, if they match any name in the $columnsToKeep, or if they look like anyColumnToKeep__anythingHere

Methods

The class defines the following methods:

__construct()

Constructor.

Signature

  • It accepts the following parameter(s):

    • $table (DataTable) —

    • $columnsToRemove (array|string) — An array of column names or a comma-separated list of column names. These columns will be removed.

    • $columnsToKeep (array|string) — An array of column names that should be kept or a comma-separated list of column names. Columns not in this list will be removed.
    • $deleteIfZeroOnly (bool) — If true, columns will be removed only if their value is 0.
    • $deleteRecursive (bool) — If true, columns will be removed in nested arrays.

filter()

See ColumnDelete.

Signature

  • It accepts the following parameter(s):

  • It does not return anything or a mixed result.

enableRecursive()

Enables/Disables recursive filtering. Whether this property is actually used is up to the derived BaseFilter class.

Signature

  • It accepts the following parameter(s):

    • $enable (bool) —
  • It does not return anything or a mixed result.

filterSubTable()

Filters a row's subtable, if one exists and is loaded in memory.

Signature

  • It accepts the following parameter(s):
    • $row (Row) — The row whose subtable should be filter.
  • It does not return anything or a mixed result.