1 layout.flexible.inc layout_flexible_template_delete_row(LayoutFlexibleTemplate $flexible_template, $original_row)

Menu callback to delete a row from a flexible template.

Parameters

LayoutFlexibleTemplate $flexible_template: The loaded flexible template object.

string $original_row: The row above or below which a new row is being inserted.

Related topics

File

core/modules/layout/layout.flexible.inc, line 828
Provides configurable (flexible) layout templates.

Code

function layout_flexible_template_delete_row(LayoutFlexibleTemplate $flexible_template, $original_row) {
  if (!isset($_GET['token']) || !backdrop_valid_token($_GET['token'], 'layout-region-' . $original_row)) {
    return MENU_ACCESS_DENIED;
  }

  $commands = array();
  $flexible_template_name = $flexible_template->name;

  unset($flexible_template->rows[$original_row]);
  layout_flexible_tempstore_set($flexible_template);

  if (backdrop_is_ajax()) {
    $commands[] = ajax_command_remove('#flexible-row--' . $original_row);

    return array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
  }
  else {
    backdrop_set_message(t('Row "@title" removed.', array('@title' => $flexible_template->title)));
    backdrop_goto('admin/structure/layouts/settings/flexible-template/' . $flexible_template_name . '/configure');
    return array();
  }
}