function _sna_blocks_archivehtml in Simple Node Archive Blocks 7.2
Same name and namespace in other branches
- 6 sna_blocks.module \_sna_blocks_archivehtml()
- 7 sna_blocks.module \_sna_blocks_archivehtml()
Theme the result set to HTML.
Parameters
array $results: Associate array in format Array([year(counter)] => Array([month(counter)] => Array([nid] => title)))
string $display_year: Which year to be shown in archive. A full numeric representation of a year, 4 digit.
string $display_month: Which month to be shown in arhive. Numeric representation of a month, with leading zeros.
string $archive_page: View name.
string $use_jquerymenu: Options to use jquerymenu 0 or 1
Return value
string An HTML string.
1 call to _sna_blocks_archivehtml()
- _sna_blocks_preprocess_sna_blocks in theme/
sna_blocks.theme.inc - @file The theme system, which controls the output of simple node archive.
File
- theme/
sna_blocks.theme.inc, line 151 - The theme system, which controls the output of simple node archive.
Code
function _sna_blocks_archivehtml($results, $display_year, $display_month, $archive_page, $use_jquerymenu) {
$output = t('No Content Posted.');
$year_items = $trail = array();
// Build the HTML.
if (!empty($results)) {
$theme_arr = array();
// Loop through earch year.
foreach ($results as $year => $months) {
$year_value = explode(' ', $year);
// $year_value[0] contain year value and $year_value[1] conatian count.
$year_url = $archive_page . '/' . $year_value[0];
// Check for active year branch and block.
$expand_year = $display_year == $year_value[0] ? TRUE : FALSE;
$children_months = array();
// If Using Jquery Menu.
if ($use_jquerymenu) {
$year_item = $month_items = array();
$year_item['link']['href'] = $year_url;
$year_item['link']['title'] = t($year_value[0]) . ' ' . $year_value[1];
$year_item['link']['has_children'] = 1;
$year_item['link']['expanded'] = 0;
$year_item['link']['options']['attributes'] = array();
$year_item['link']['hidden'] = 0;
if ($expand_year) {
$trail[0] = $year_item['link']['href'];
}
$expand_year = TRUE;
}
if ($expand_year) {
// Loop through active year and show month.
foreach ($months as $month => $nodes) {
$month_value = explode(' ', $month);
// $month_value[0] contain month and $month_value[1] conatian count.
$month_url = $archive_page . '/' . $year_value[0] . '/' . date('m', strtotime($month_value[0] . '-' . $year_value[0]));
// Check for active month and block.
$expand_month = $display_year == $year_value[0] && $display_month == $month_value[0] ? TRUE : FALSE;
$children_nodes = array();
// If Using Jquery Menu.
if ($use_jquerymenu) {
$month_item = $node_items = array();
$month_item['link']['href'] = $month_url;
$month_item['link']['title'] = t($month_value[0]) . ' ' . $month_value[1];
$month_item['link']['has_children'] = 1;
$month_item['link']['expanded'] = 0;
$month_item['link']['options']['attributes'] = array();
$month_item['link']['hidden'] = 0;
if ($expand_month) {
$trail[0] = $year_item['link']['href'];
$trail[1] = $month_item['link']['href'];
}
$expand_month = TRUE;
}
if ($expand_month) {
$count = 1;
// Loop through acitive month and show node.
foreach ($nodes as $nid => $title) {
// If Using Jquery Menu.
if ($use_jquerymenu) {
$node_item = array();
}
// $archive_items number of nodes display in expanded archive.
$children_nodes[] = l($title, 'node/' . $nid);
// If Using Jquery Menu.
if ($use_jquerymenu) {
$node_item['link']['href'] = 'node/' . $nid;
$node_item['link']['title'] = $title;
$node_item['link']['has_children'] = 0;
$node_item['link']['expanded'] = 0;
$node_item['link']['options']['attributes'] = array();
$node_item['link']['hidden'] = 0;
}
$count = $count != 0 ? $count + 1 : 0;
// If Using Jquery Menu.
if ($use_jquerymenu) {
$node_items[] = $node_item;
}
}
// If Using Jquery Menu.
if ($use_jquerymenu) {
$month_item['below'] = $node_items;
$month_items[] = $month_item;
}
}
$children_months[] = array(
'data' => l(t($month_value[0]), $month_url) . ' <span>' . $month_value[1] . '</span>',
'children' => $children_nodes,
);
}
// If Using Jquery Menu.
if ($use_jquerymenu) {
$year_item['below'] = $month_items;
$year_items[] = $year_item;
}
}
$theme_arr[] = array(
'data' => l(t($year_value[0]), $year_url) . ' <span>' . $year_value[1] . '</span>',
'children' => $children_months,
);
}
// If Using Jquery Menu.
if ($use_jquerymenu) {
$output = theme('jquerymenu_menu', array(
'tree' => $year_items,
'trail' => $trail,
));
}
else {
$output = theme('item_list', array(
'items' => $theme_arr,
));
}
}
else {
// Term is not tagged with any node.
$output = t('No posts available');
}
return $output;
}