Documentation

Widgets
in package

Provided functions for the display of widgets

Table of Contents

Properties

$widget_areas  : mixed

Methods

add()  : mixed
Add a widget to the list of widgets for a specific area
addOnce()  : mixed
Add a widget to an area, but only once.
area()  : mixed
Render a widget area, and output directly
checkDisplayConditions()  : bool
Check whether the widget is allowed to be displayed
hasWidgets()  : bool
Does the specified widget area have widgets?
instantiate()  : Widget
Create an instance of a specific widget in memory
remove()  : mixed
Remove a widget to the list of widgets for a specific area
render()  : string
Instantiate, import settings, and render
renderArea()  : string
Draw the widgets for a specific area
infobox()  : mixed
Render extra widget info for admins

Properties

$widget_areas

private static mixed $widget_areas = array()

Methods

add()

Add a widget to the list of widgets for a specific area

public static add(int|string $area_id, string $name, array<string|int, mixed> $settings[, string $heading = '' ][, string $template = '' ][, string $columns = null ]) : mixed
Parameters
$area_id : int|string

The widget area to add the widget to

$name : string

The name of the widget to add

$settings : array<string|int, mixed>

The widget settings to use

$heading : string = ''

HTML H2 rendered front-end within widget

$template : string = ''

Optional wrapping template name

$columns : string = null

addOnce()

Add a widget to an area, but only once.

public static addOnce(int|string $area_id, string $name, array<string|int, mixed> $settings[, string $heading = '' ][, string $template = '' ][, string $columns = null ]) : mixed

Settings will be overridden by subsequent calls - last widget wins.

Parameters
$area_id : int|string

The widget area to add the widget to

$name : string

The name of the widget to add

$settings : array<string|int, mixed>

The widget settings to use

$heading : string = ''

HTML H2 rendered front-end within widget

$template : string = ''

Optional wrapping template name

$columns : string = null

area()

Render a widget area, and output directly

public static area(mixed $area_name) : mixed

Use Widgets::renderArea instead

Parameters
$area_name : mixed

checkDisplayConditions()

Check whether the widget is allowed to be displayed

public static checkDisplayConditions(array<string|int, mixed> $env, array<string|int, mixed> $conditions) : bool
Parameters
$env : array<string|int, mixed>

Calling environment, e.g. page id

$conditions : array<string|int, mixed>

Conditions to check; each condition would be an array witj 'field', 'op', 'val' keys

Return values
bool —

True if conditions match and display is allowed, false otherwise

hasWidgets()

Does the specified widget area have widgets?

public static hasWidgets(string $area_name) : bool
Parameters
$area_name : string

The name of the widget area to query.

Tags
tag

api

designer-api

Return values
bool

instantiate()

Create an instance of a specific widget in memory

public static instantiate(string $name) : Widget
Parameters
$name : string

The name of the widget to instantiate.

Return values
Widget —

The instance

remove()

Remove a widget to the list of widgets for a specific area

public static remove(string|int $area_id, string $name) : mixed
Parameters
$area_id : string|int

The widget area to add the widget to

$name : string

The name of the widget to remove

render()

Instantiate, import settings, and render

public static render(int|string $orientation, string $name, array<string|int, mixed> $settings[, string $pre_html = null ][, string $post_html = null ][, string $heading = null ][, string $template = null ]) : string
Parameters
$orientation : int|string

ORIENTATION constant or name WidgetArea

$name : string

Class name of the widget

$settings : array<string|int, mixed>

Widget settings (keys and values vary with widget subclass)

$pre_html : string = null

HTML to go before the rendered widget

$post_html : string = null

HTML to go after the rendered widget

$heading : string = null

String Optional HTML H2 rendered on front-end of given widget

$template : string = null

String Optional wrapping template name

Return values
string —

Front-end HTML of widget

renderArea()

Draw the widgets for a specific area

public static renderArea(string $area_name[, bool $enable_columns = false ]) : string

The available widget areas are defined in the file. Typically there are two areas defined, 'sidebar' and 'embedded'.

Parameters
$area_name : string

The name of the widget area to draw.

$enable_columns : bool = false

Enable grouping widgets into visual columns. Default of false

Return values
string —

HTML representing the rendered widgets

infobox()

Render extra widget info for admins

private static infobox(mixed $inst) : mixed
Parameters
$inst : mixed
On this page

Search results