Abstract Class humhub\modules\ui\filter\widgets\FilterNavigation

Inheritancehumhub\modules\ui\filter\widgets\FilterNavigation » humhub\widgets\JsWidget » humhub\components\Widget » yii\base\Widget
Subclasseshumhub\modules\stream\widgets\WallStreamFilterNavigation
Available since version1.3

This widget is used to render the filter navigation of a filter component.

A FilterNavigation groups filters into panels and blocks whereas a filter block is part of a filter panel and can contain multiple filter.

Subclasses should initialize the default filter state within the initFilterPanels(), initFilterBlocks() and initFilters() functions.

The default view expects the following format for the different components:

  • $filterPanels - Just holds an array of filter block definitions associated by an panel index. An block definition array has to be compatible with the \humhub\modules\ui\filter\widgets\StreamFilterBlock widget config.

  • $filterBlocks - Holds an array of all block definitions containing the related filters with block ids as array keys.

  • $filters - Holds a flat array of filter definitions. A filter definition has to be compatible with \humhub\modules\ui\filter\widgets\StreamFilter widget config.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
addFilter() Adds a Filter with given $filterId and filter definition to the filter block with the given $blockId. humhub\modules\ui\filter\widgets\FilterNavigation
addFilterBlock() Adds a new filter block to the given $panel. humhub\modules\ui\filter\widgets\FilterNavigation
filterOutEmptyPanels() humhub\modules\ui\filter\widgets\FilterNavigation
getId() Returns the html id of this widget, if no id is set this function will generate an id if $autoGenerate is set to true (default). humhub\widgets\JsWidget
init() humhub\modules\ui\filter\widgets\FilterNavigation
initDefinitionFilters() Adds additional filters of the filter definition, which are not already part of the default filter setting. humhub\modules\ui\filter\widgets\FilterNavigation
isAllowedFilter() Checks if the given $filterId is allowed by the definition. humhub\modules\ui\filter\widgets\FilterNavigation
process() Process is a wrapper for the run method humhub\components\Widget
run() Default implementation of JsWidget. humhub\modules\ui\filter\widgets\FilterNavigation
setDefaultOptions() Sets some default data options required by all widgets as the widget implementation and the widget evetns and initialization trigger. humhub\widgets\JsWidget
widget() Creates a widget instance and runs it. humhub\components\Widget

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
getAttributes() Returns all html attributes for used by this widget and will normally inserted in the widgets root html element. humhub\widgets\JsWidget
getData() Returns an array of data-* attributes to configure your clientside js widget. humhub\widgets\JsWidget
getOptions() Assembles all widget attributes and data settings of this widget. humhub\widgets\JsWidget
initFilterBlocks() Initialization logic for default filter blocks. humhub\modules\ui\filter\widgets\FilterNavigation
initFilterPanels() Initialization logic for default filter panels humhub\modules\ui\filter\widgets\FilterNavigation
initFilters() Initialization logic for default filter blocks. humhub\modules\ui\filter\widgets\FilterNavigation

Events

Hide inherited events

EventTypeDescriptionDefined By
EVENT_CREATE humhub\libs\WidgetCreateEvent An event raised before creating a widget. humhub\components\Widget

Property Details

$defaultBlock public property

Can be set to define a default block to add filters with no specific block relation.

public string $defaultBlock null
$definition public property

The filter definition can be used to manipulate the default settings

public array $definition = []
$filterBlocks public property

Filter blocks separate filter categories in order to group filters

public array $filterBlocks = []
$filterPanels public property

Filter panels define separate filter container

public array $filterPanels = []
$filters public property

List of all active filter definitions

public array $filters = []
$jsWidget public property
public string $jsWidget 'ui.Filter'
$view public property

View

public string $view 'filterNavigation'

Method Details

addFilter() public method

Adds a Filter with given $filterId and filter definition to the filter block with the given $blockId.

Note: This function will only add the given filter if it is allowed by the $definition and not already set.

public void addFilter ( $filter, $blockId null )
$filter

Array filter definition

$blockId

String block id

addFilterBlock() public method

Adds a new filter block to the given $panel.

public void addFilterBlock ( $id, $definition, $panel )
$id

String filter block id

$definition
$panel
filterOutEmptyPanels() public method

public void filterOutEmptyPanels ( )
init() public method

public void init ( )
initDefinitionFilters() public method

Adds additional filters of the filter definition, which are not already part of the default filter setting.

public void initDefinitionFilters ( )
initFilterBlocks() protected abstract method

Initialization logic for default filter blocks.

This function can make use of the addFilterBlock() to add filter blocks to the previously initialized panels

protected abstract void initFilterBlocks ( )
initFilterPanels() protected abstract method

Initialization logic for default filter panels

protected abstract void initFilterPanels ( )
initFilters() protected abstract method

Initialization logic for default filter blocks.

This function can make use of the addFilter() to add filters the previously initialized blocks

protected abstract void initFilters ( )
isAllowedFilter() public method

Checks if the given $filterId is allowed by the definition.

public boolean isAllowedFilter ( $filterId )
$filterId
run() public method

Default implementation of JsWidget.

This will render a widget html element specified by $container and $content and the given $options/$event attributes. This function should be overwritten for widgets with a more complex rendering.

public string run ( )