File: D:/HostingSpaces/SBogers10/deensekroon.komma-mediadesign.nl/wwwroot/php/page_home.php
<?php
/*
Deense Kroon
Homepage
Mike Ontwerpt 2012
www.mikeontwerpt.nl
initHome();
showLargeBanner();
showPopular();
showCollection();
*/
function initHome(){
$output = '';
$output .= showLargeBanner();
$output .= showAllProducts(5);
return $output;
}
function showLargeBanner(){
global $mysqli;
include './lang/'.$_SESSION['lang'].'.php';
/* load & display large banner */
$output = '';
$output .= '<div class="flexable-home-banner">';
// Generate output
$output .= '<div class="banner-image">';
$output .= '<div class="swiper-container">';
$output .= '<div class="swiper-wrapper">';
// Fetch the last banner
$query = 'SELECT b.title, b.bannerimage, b.url
FROM banners AS b, content_status AS s
WHERE type = 1
AND s.active = 1
AND s.itemId = b.id
AND s.linkname = "banners"
AND b.published = 1
ORDER BY itemOrder DESC';
$result = $mysqli->query($query);
// If no banner is found return an empty string
if( ! $result->num_rows) return '';
// Fetch result
while($record = $result->fetch_assoc())
{
// Gather data
$title = fromDatabase($record['title']);
$url = $record['url'];
// if(substr($url,0,7) != 'http://' && !empty($url)) $url = 'http://'.$url;
// Convert shortcode to image
$shortcode = substr($record['bannerimage'], 1, -1);
$mediaResult = $mysqli->query('SELECT title, path FROM media_files WHERE shortcode = "'.$shortcode.'" LIMIT 1');
$mediaRecord = $mediaResult->fetch_assoc();
$filename = $mediaRecord['path'];
$output .= '<div class="swiper-slide">';
if(!empty($url)) $output .= '<a href="'.$url.'">';
$output .= '<img src="/images/uploads/'.$filename.'" alt="'.$title.'" />';
if(!empty($url)) $output .= '</a>';
$output .= '</div>'; // End swiper-slide
}
$output .= '</div>'; // End swiper-wrapper
$output .= '</div>'; // End swiper-container
$output .= '</div>'; // End banner-image
//--------------- END BANNER ---------------//
// Featured images
$arrNew = array();
$query = 'SELECT DISTINCT p.id AS productId, p.titleNL, p.published, p.catId, p.brandId, p.price, p.discountPrice, p.thumb, p.hover, p.productOrder
FROM product_products AS p, content_status AS s
WHERE s.itemId = p.id
AND s.active = 1
AND s.linkname = "product_products"
AND p.published = 1
AND p.isNew = 1
ORDER BY p.productOrder DESC';
if($result = $mysqli->query($query)){
$i = 0;
while($record = $result->fetch_assoc()){
$id = $record['productId'];
$title = $record['titleNL'];
$linkTitle = linkname($title);
//thumbnail
# thumbnail
$thumbShortCode = $record['thumb'];
$hoverShortCode = $record['hover'];
$thumb = $hover = '';
$thumbQuery = 'SELECT filename_medium, filename_small
FROM media_files
WHERE shortcode = "'.$thumbShortCode.'" LIMIT 1';
if($thumbResult = $mysqli->query($thumbQuery)){
$thumbRecord = $thumbResult->fetch_assoc();
if(!empty($thumbRecord['filename_small']) && is_file( DOCUMENT_ROOT . 'images/uploads/'.$thumbRecord['filename_small'])){
$thumb = '/images/uploads/'.$thumbRecord['filename_small'];
}
else if(!empty($thumbRecord['filename_medium']) && is_file( DOCUMENT_ROOT . '/images/uploads/'.$thumbRecord['filename_medium'])){
$thumb = '/images/uploads/'.$thumbRecord['filename_medium'];
}
}
# hover ?
if($hoverShortCode != $thumbShortCode && ! empty($hoverShortCode))
{
$hoverQuery = 'SELECT filename_medium, filename_small
FROM media_files
WHERE shortcode = "'.$hoverShortCode.'" LIMIT 1';
if($hoverResult = $mysqli->query($hoverQuery)){
$hoverRecord = $hoverResult->fetch_assoc();
#hover
if(!empty($hoverRecord['filename_small']) && is_file(DOCUMENT_ROOT . '/images/uploads/'.$hoverRecord['filename_small']) ){ $hover = '/images/uploads/'.$hoverRecord['filename_small']; }
else{ $hover = '/images/uploads/'.$hoverRecord['filename_medium']; }
}
}
else
{
$hover = '';
}
#thumb fallback
if(empty($thumb)){
// if no image
$thumb = '/images/structure/noimage.jpg';
}
# save in array
$arrNew[$i] = array();
$arrNew[$i]['id'] = $id;
$arrNew[$i]['title'] = $linkTitle;
$arrNew[$i]['linkTitle'] = $linkTitle;
$arrNew[$i]['thumb'] = $thumb;
$arrNew[$i]['hover'] = $hover;
$i++;
}
shuffle($arrNew);
$output .= '<div class="featured-products">';
#popular
if( ! empty($arrNew))
{
$output .= '<div class="product-thumb-holder">';
//output image
$output .= '<div class="product-thumb-image">';
$output .= '<img src="/images/structure/loading.gif" alt="deense kroon laadt '.$arrNew[0]['title'].'" class="loading" />';
$output .= '<a href="/toont-het-artikel/'.$arrNew[0]['linkTitle'].'-'.$arrNew[0]['id'].'/">';
if(!empty($arrNew[0]['hover'])) $output .= '<img src="'.$arrNew[0]['hover'].'" alt="Deense Kroon sieraad genaamd '.$arrNew[0]['title'].'" class="collection_hover" id="product'.$arrNew[0]['id'].'"/>';
$output .= '<img src="/images/structure/spacer.gif" data-src="'.$arrNew[0]['thumb'].'" alt="Deense Kroon sieraad genaamd '.$arrNew[0]['title'].'" class="preload" />';
$output .= '</a>';
$output .= '</div>';
$output .= '</div>';
$output .= '<div class="product-thumb-holder">';
//output image
$output .= '<div class="product-thumb-image">';
$output .= '<img src="/images/structure/loading.gif" alt="deense kroon laadt '.$arrNew[1]['title'].'" class="loading" />';
$output .= '<a href="/toont-het-artikel/'.$arrNew[1]['linkTitle'].'-'.$arrNew[1]['id'].'/">';
if(!empty($arrNew[1]['hover'])) $output .= '<img src="'.$arrNew[1]['hover'].'" alt="Deense Kroon sieraad genaamd '.$arrNew[1]['title'].'" class="collection_hover" id="product'.$arrNew[1]['id'].'"/>';
$output .= '<img src="/images/structure/spacer.gif" data-src="'.$arrNew[1]['thumb'].'" alt="Deense Kroon sieraad genaamd '.$arrNew[1]['title'].'" class="preload" />';
$output .= '</a>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '<div class="clear"></div>';
}
}
else{
echo $mysqli->error;
}
$output .= '</div>';
return $output;
}