function nodeorder_admin_display_form in Node Order 7
Same name and namespace in other branches
- 6 nodeorder.admin.inc \nodeorder_admin_display_form()
Generate main blocks administration form.
1 string reference to 'nodeorder_admin_display_form'
- nodeorder_menu in ./
nodeorder.module - Implements hook_menu().
File
- includes/
nodeorder.admin.inc, line 52 - Admin page callbacks for the nodeorder module.
Code
function nodeorder_admin_display_form($form, &$form_state, $tid) {
global $pager_page_array, $pager_total, $pager_total_items;
$page = isset($_GET['page']) ? $_GET['page'] : 0;
$page_increment = variable_get('taxonomy_terms_per_page_admin', 100);
// Number of terms per page.
$page_entries = 0;
// Elements shown on this page.
$before_entries = 0;
// Elements at the root level before this page.
$after_entries = 0;
// Elements at the root level after this page.
$root_entries = 0;
// Elements at the root level on this page.
$term = taxonomy_term_load($tid);
// Build form tree
$form = array(
'#tree' => TRUE,
'#parent_fields' => FALSE,
'#term' => $term,
);
drupal_set_title(t('Order nodes for <em>%term_name</em>', array(
'%term_name' => $term->name,
)), PASS_THROUGH);
$node_ids = taxonomy_select_nodes($tid, FALSE, FALSE, array(
't.weight' => 'ASC',
));
$nodes = node_load_multiple($node_ids);
$node_count = count($nodes);
// Weights range from -delta to +delta, so delta should be at least half
// of the amount of blocks present. This makes sure all blocks in the same
// region get an unique weight.
$weight_delta = round($node_count / 2);
foreach ($nodes as $node) {
$form[$node->nid]['#node'] = $node;
$form[$node->nid]['title'] = array(
'#markup' => check_plain($node->title),
);
$form[$node->nid]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for @title', array(
'@title' => $node->title,
)),
'#title_display' => 'invisible',
'#delta' => $weight_delta,
'#default_value' => $node->nodeorder[$tid]['weight'],
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save order'),
);
return $form;
}