function headerimage_block_configure in Header image 7
Same name and namespace in other branches
- 5 headerimage.module \headerimage_block_configure()
- 6 headerimage.module \headerimage_block_configure()
Implementation of hook_block_configure().
File
- ./
headerimage.module, line 143 - headerimage.module Conditionally display an node in a block.
Code
function headerimage_block_configure($delta = '') {
$query = db_select('headerimage', 'hi');
$query
->fields('hi', array(
'weight',
));
$query
->fields('n', array(
'title',
'nid',
));
$query
->join('node', 'n', 'n.nid = hi.nid AND hi.block = :delta', array(
':delta' => $delta,
));
$query
->orderBy('weight', 'ASC');
$query
->orderBy('nid', 'ASC');
$result = $query
->execute();
// Table with image set details
$rows = array();
foreach ($result as $data) {
$rows[] = array(
'node' => check_plain($data->title),
'weight' => $data->weight,
'edit' => l(t('Edit'), "node/{$data->nid}/edit"),
);
}
if (empty($rows)) {
$rows[] = array(
array(
'data' => t('No Header Image nodes assigned to this block.'),
'colspan' => '3',
),
);
}
$header = array(
t('Node'),
t('Weight'),
array(
'data' => t('Operation'),
'colspan' => '1',
),
);
$output = theme('table', array(
'header' => $header,
'rows' => $rows,
'attributes' => array(
'id' => 'imageblock',
),
));
// Pack the tabel in form as markup text.
$form['headerimage']['description'] = array(
'#prefix' => '<p>',
'#value' => t('The table below contains the nodes which will be displayed in this block when there condition evaluates to true.'),
'#suffix' => '</p>',
);
$form['headerimage']['table'] = array(
'#prefix' => '<div>',
'#markup' => $output,
'#suffix' => '</div>',
);
$form['headerimage']['random_fallback'] = array(
'#type' => 'checkbox',
'#title' => t('Enable a random fallback selection'),
'#default_value' => variable_get('headerimage_block_' . $delta . '_random_fallback', 0),
'#description' => t('If no node is selected by the conditions, select a random node from those assigned to this block.'),
);
return $form;
}