sc_widget_name

The sc_widget_name() macro returns the name of the widget currently being executed, allowing you to identify which widget is being processed and apply specific dynamic configurations.

This macro has no parameters.

Example

// Get the widget name to change its title
$widgetName = sc_widget_name();

// Check the widget name
if ($widgetName == 'widget1') {
    sc_widget_config([
        'title' => 'Sales Widget',
    ]);
}

In the example above, the sc_widget_name() macro is used to identify the widget being executed. If the name is widget1, the title is dynamically updated using the sc_widget_config() macro.

See also

For additional widget customization, see the macros: sc_widget_config() and sc_widget_data().