function sna_blocks_block_view in Simple Node Archive Blocks 7
Implements hook_block_view().
File
- ./
sna_blocks.module, line 88 - Provide a simple node archive block
Code
function sna_blocks_block_view($delta = '') {
$block = array();
$archive_items = variable_get('sna_blocks_items', 0);
$arg = explode('/', $_GET['q']);
$year = $arg[0] == 'sna' && $arg[1] != '' && is_numeric($arg[1]) ? $arg[1] : '';
$month = $arg[0] == 'sna' && $arg[2] != '00' && is_numeric($arg[2]) ? date('F', mktime(0, 0, 0, $arg[2])) : '';
// Node archive.
$block_types = variable_get('sna_blocks_block_types', array(
'page',
));
foreach ($block_types as $type => $value) {
if ($delta == 'sna-node-' . $value) {
$block['subject'] = t('SNA Node type @name', array(
'@name' => $value,
));
$block['content'] = theme('sna_blocks_node', array(
'value' => $value,
'archive_items' => $archive_items,
'year' => $year,
'month' => $month,
));
}
}
// Taxonomy Archive.
$taxonomy_options = variable_get('sna_blocks_taxonomy_options', array());
$taxonomy_archive = variable_get('sna_blocks_taxonomy_items', array());
foreach ($taxonomy_archive as $type => $value) {
if ($delta == 'sna-taxo-' . $value) {
$block['subject'] = t('SNA Taxonomy type @name', array(
'@name' => $taxonomy_options[$value],
));
$block['content'] = theme('sna_blocks_taxonomy', array(
'value' => $value,
'archive_items' => $archive_items,
'year' => $year,
'month' => $month,
));
}
}
return $block;
}