Commit a8c2a74c authored by Eric Bremner's avatar Eric Bremner
Browse files

FDSU-1829: Ensuring that when only one homepage banner is present, works as expected.

parent 78d05a7d
......@@ -65,6 +65,14 @@ function uw_virtual_site_homepage_page_alter(&$page) {
$pagenumber = 0;
$boxes = '';
$num_of_images = 0;
// Get the number of images in the homepage banners.
foreach($page['uw-virtual-site-homepage']['field_uw_homepage_banners'] as $key => $value) {
if(is_int($key)) {
$num_of_images++;
}
}
// While there is a continue, process the homepage banners.
while($continue) {
......@@ -126,26 +134,8 @@ function uw_virtual_site_homepage_page_alter(&$page) {
}
}
if(isset($page['uw-virtual-site-homepage']['field_uw_homepage_banners'][$index]['entity']['field_collection_item'][$fc_id]['field_uw_homepage_banners_link']['#items'][0]['url'])) {
$html .= '</a>';
}
// More html.
$html .= '<div class="banner-controls">';
// Set previous and next buttons.
$html .= '<button id="previous_banner" class="tabs-previous"><</button>';
$html .= '<button id="next_banner" class="tabs-next">></button>';
// More html to close the homepage banners.
$html .= '</div>';
$html .= '</figure>';
if($pagenumber == 1) {
$boxes .= '<li><a href="" title="display banner #' . $pagenumber . '" class="hpb_selected" data-pagenumber="' . $pagenumber .'"><span class="element-invisible">Display banner #</span>' . $pagenumber . '</a></li>';
}
else {
$boxes .= '<li><a href="" title="display banner #' . $pagenumber . '" data-pagenumber="' . $pagenumber .'"><span class="element-invisible">Display banner #</span>' . $pagenumber . '</a></li>';
if(isset($page['uw-virtual-site-homepage']['field_uw_homepage_banners'][$index]['entity']['field_collection_item'][$fc_id]['field_uw_homepage_banners_link']['#items'][0]['url'])) {
$html .= '</a>';
}
// Increment the index.
......@@ -155,18 +145,42 @@ function uw_virtual_site_homepage_page_alter(&$page) {
if(!(isset($page['uw-virtual-site-homepage']['field_uw_homepage_banners'][$index]))) {
$continue = false;
}
// If there is more than one image add the paginator blocks.
if($num_of_images > 1) {
// More html.
$html .= '<div class="banner-controls">';
// Set previous and next buttons.
$html .= '<button id="previous_banner" class="tabs-previous"><</button>';
$html .= '<button id="next_banner" class="tabs-next">></button>';
// More html to close the homepage banners.
$html .= '</div>';
$html .= '</figure>';
if($pagenumber == 1) {
$boxes .= '<li><a href="" title="display banner #' . $pagenumber . '" class="hpb_selected" data-pagenumber="' . $pagenumber .'"><span class="element-invisible">Display banner #</span>' . $pagenumber . '</a></li>';
}
else {
$boxes .= '<li><a href="" title="display banner #' . $pagenumber . '" data-pagenumber="' . $pagenumber .'"><span class="element-invisible">Display banner #</span>' . $pagenumber . '</a></li>';
}
}
}
// Final closing html and play/pause button.
$html .= '</div>';
$html .= '<button class="slideshow-control pause" title="Pause">';
$html .= '<span class="element-invisible">Pause banner slideshow</span>';
$html .= '<span class="icon-pause"></span>';
$html .= '</button>';
$html .= '<ul class="homepage_banners_paginator">';
$html .= $boxes;
$html .= '</ul>';
$html .= '</div>';
// If there is more than one image, add the Play/Pause button.
if($num_of_images > 1) {
// Final closing html and play/pause button.
$html .= '</div>';
$html .= '<button class="slideshow-control pause" title="Pause">';
$html .= '<span class="element-invisible">Pause banner slideshow</span>';
$html .= '<span class="icon-pause"></span>';
$html .= '</button>';
$html .= '<ul class="homepage_banners_paginator">';
$html .= $boxes;
$html .= '</ul>';
$html .= '</div>';
}
// Set the html to the page variable.
$page['uw_virtual_page_homepage_banners_html'] = $html;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment