function headerimage_block_configure in Header image 6
Same name and namespace in other branches
- 5 headerimage.module \headerimage_block_configure()
- 7 headerimage.module \headerimage_block_configure()
Return a form with a list of Header Image nodes
Nodes assigned to Header Image block $delta are listed with weight and edit link
Parameters
$delta: Header Image block delta
Return value
form array
1 call to headerimage_block_configure()
- headerimage_block in ./
headerimage.module - Implementation of hook_block().
File
- ./
headerimage.module, line 506 - headerimage.module Conditionally display an node in a block.
Code
function headerimage_block_configure($delta) {
$result = db_query("SELECT title, weight, n.nid FROM {headerimage} hi JOIN {node} n ON n.nid = hi.nid AND hi.block = %d ORDER BY weight, nid ASC", $delta);
// Table with image set details
$rows = array();
while ($data = db_fetch_object($result)) {
$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', $header, $rows, 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>',
'#value' => $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;
}