1 layout.admin.inc | layout_reorder_form($form, &$form_state) |
Reorder the order of layouts at the same path.
Related topics
File
- core/
modules/ layout/ layout.admin.inc, line 2432 - Admin page callbacks for the Layout module.
Code
function layout_reorder_form($form, &$form_state) {
if (!isset($form_state['layouts'])) {
$layout_list = isset($_GET['layouts']) ? $_GET['layouts'] : array();
$layouts = array();
if (is_array($layout_list)) {
$layouts = layout_load_multiple($layout_list);
}
$form_state['layouts'] = $layouts;
}
$layouts = $form_state['layouts'];
$form['#tree'] = TRUE;
// Sanity check.
if (empty($layouts)) {
backdrop_set_message(t('No layouts specified to reorder.'));
return $form;
}
$form['help'] = array(
'#type' => 'help',
'#markup' => t('Layouts at the same path are selected based on the first layout that matches its conditions. Reorder the layouts on this page to affect the layout that will be used first.'),
);
$form['layouts'] = array(
'#theme' => 'layout_reorder_layouts',
);
$layout_count = count($layouts);
foreach ($layouts as $layout) {
$form['layouts'][$layout->name]['title'] = array(
'#markup' => check_plain($layout->title),
);
$form['layouts'][$layout->name]['weight'] = array(
'#type' => 'weight',
'#delta' => $layout_count,
'#default_value' => $layout->weight,
);
}
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
);
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => 'admin/structure/layouts',
'#options' => array(
'attributes' => array('class' => array('form-cancel')),
),
);
return $form;
}