sc_widget_type
|
|
The sc_widget_type macro returns the type of the widget being executed, allowing changes based on the identified type using the sc_widget_config and sc_widget_data macros.
Possible return values for the sc_widget_type macro are:
- link – Indicates a Link widget.
- index – Indicates an Index widget.
- divider – Indicates a Divider widget.
This macro does not receive any parameters.
Example
Below is an example of how to change the widget properties based on its type.
$type = sc_widget_type();
switch ($type) {
case 'link':
sc_widget_config([
'title' => 'Link-type Widget',
'border-color' => 'red',
]);
break;
case 'index':
sc_widget_config([
'title' => 'Index-type Widget',
'legend' => 'Index legend',
'background-color' => '#4682B4',
'border-color' => '#87CEEB',
]);
break;
case 'divider':
sc_widget_config([
'title' => 'Divider-type Widget',
'subtitle' => 'Divider description',
'background-color' => '#4682B4',
'border-color' => '#87CEEB',
]);
break;
}
|
|