function views_blogspot_archive_without_link in Views Blogspot Archive 8
Theme the result set to HTML.
Parameters
array $results: Associate array in format Array([year(counter)] => Array([month(counter)] => Array([nid] => title)))
Return value
array An HTML string.
1 call to views_blogspot_archive_without_link()
- template_preprocess_views_blogspot_archive_view_archive in templates/
views_blogspot_archive.theme.inc - Prepares variables for view templates.
File
- templates/
views_blogspot_archive.theme.inc, line 252 - Preprocessors and helper functions to make theming easier.
Code
function views_blogspot_archive_without_link(array $results) {
$items = array();
if (!empty($results)) {
foreach ($results as $year => $months) {
// $year_parts[0] contain year value and $year_parts[1] contains count.
$year_parts = explode(' ', $year);
$child_months = array();
// Loop through active year's month.
foreach ($months as $month => $entities) {
// $month_parts[0] contain int month and current interface month. $month_parts[1] contains count.
$month_parts = explode(' ', $month);
$month_items = explode('::', $month_parts[0]);
$child_entities = array();
$count = 1;
// Loop through active month's node.
foreach ($entities as $entity) {
// $archive_items number of nodes display in expanded archive.
$link_obj = Link::fromTextAndUrl(t($entity
->label()), $entity
->toUrl());
$link_element = $link_obj
->toRenderable();
$child_entities[] = render($link_element);
$count = $count != 0 ? $count + 1 : 0;
}
$child_months[] = array(
'#markup' => '<span class="caret"><a>' . t($month_items[1]) . '</a></span> <span>' . $month_parts[1] . '</span>',
'children' => $child_entities,
);
}
$items[] = array(
'#markup' => '<span class="caret"><a>' . t($year_parts[0]) . '</a></span> <span>' . $year_parts[1] . '</span>',
'children' => $child_months,
);
}
}
else {
$items[] = t('No posts available.');
}
return $items;
}