sc_widget_type

La macro sc_widget_type devuelve el tipo del widget en ejecución, permitiendo realizar cambios según el tipo identificado, utilizando las macros sc_widget_config y sc_widget_data.

Los posibles valores de retorno de la macro sc_widget_type son:

  • link – Indica un widget de enlace.
  • index – Indica un widget de índice.
  • divider – Indica un widget de división.

Esta macro no recibe parámetros.

Ejemplo

A continuación, un ejemplo de cómo modificar las propiedades del widget según su tipo.


$type = sc_widget_type();

switch ($type) {
  case 'link':
    sc_widget_config([
      'title' => 'Widget de tipo enlace',
      'border-color' => 'red',
    ]);
    break;

  case 'index':
    sc_widget_config([
      'title' => 'Widget de tipo índice',
      'legend' => 'Leyenda del índice',
      'background-color' => '#4682B4',
      'border-color' => '#87CEEB',
    ]);
    break;

  case 'divider':
    sc_widget_config([
      'title' => 'Widget de tipo división',
      'subtitle' => 'Descripción del divisor',
      'background-color' => '#4682B4',
      'border-color' => '#87CEEB',
    ]);
    break;
}