<?php
//get shop page's title
$t = $site->pageTitle($s['shop_page']);
$seo_pageTitle = seo_str($t);
//get cat ID from url key
$cat = $site->catFromKey($_GET['junk']);
//add meta tags to the page if showing a sub category
$meta = $mysql->get_array($mysql->query("blurb,meta_title,meta_keywords,meta_desc,live", "fs_shop_cats", "ID = $cat LIMIT 1"));
//if cat is not live, redirect to error page
if($meta['live'] == 'n')
{
header("Location: /2/Error");
exit;
}
//meta tags
$array['page_title'] = (!empty($meta['meta_title'])) ? stripslashes($meta['meta_title']) : $array['page_title'];
$array['keywords'] = (!empty($meta['meta_keywords'])) ? stripslashes($meta['meta_keywords']) : $array['keywords'];
$array['meta_desc'] = (!empty($meta['meta_desc'])) ? stripslashes($meta['meta_desc']) : $array['meta_desc'];
if(strstr($meta['blurb'], '<'))
{
$catBlurb = (!empty($meta['blurb'])) ? stripslashes($meta['blurb']) : '';
}
else
{
$catBlurb = (!empty($meta['blurb'])) ? '<p>'.nl2br(stripslashes($meta['blurb'])).'</p>' : '';
}
//bread crumbs
if(!empty($cat))
{
$c = explode("\n", $site->cat_levels($cat));
if(is_array($c))
{
$crumbs .= '<a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'">'.$t.'</a> &gt; ';
$last = (sizeof($c)-2);
for($x = 0; $x < sizeof($c); $x++)
{
list($key, $name) = explode("#", $c[$x]);
$crumbs .= ($x<$last) ? '<a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$key.'">' : '';
$crumbs .= ($x<$last) ? $name : "<strong>$name</strong>";
$crumbs .= ($x<$last) ? '</a> &gt; ' : '';
}
}
}
//show all products in this cat
$products = '<h1>'.$t.'</h1>';
$products .= '<p id="shopCrumbs">'.$crumbs.'</p>';
$products .= $catBlurb.'<div id="prodlist">';
$query = $mysql->query("ID,name,price,sale_price,thumb_image,url_key", "fs_shop_products", "(cat = $cat OR additional_cats LIKE '%|$cat|%') AND cat > 0 AND hide = 'n' ORDER BY CASE WHEN cat=$cat THEN `order` ELSE `order`+1000 END ASC");
while($data = $mysql->get_array($query))
{
$price = $site->currency_symbol($data['price']);
$shortName = (strlen($data['name']) > 42) ? substr($data['name'], 0, 42).'...' : $data['name'];
if($data['sale_price'] > 0){$price = 'WAS <span class="sale">'.$site->currency_symbol($data['price']).'</span><br /><strong>NOW '.$site->currency_symbol($data['sale_price']).'</strong>';}
$size = $site->shop_settings('catimage_height,catimage_width');
$outOfStock = (!$site->in_stock($data['ID'])) ? '<br /><strong>Out of stock</strong>' : '';
$products .= '<table border="0" cellspacing="0" cellpadding="0" width="'.$size['catimage_width'].'">
<tr>
<th><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$data['url_key'].'"><img src="/inc/shop/images/clear.gif" alt="'.$data['name'].'" width="'.$size['catimage_width'].'" height="'.$size['catimage_height'].'" border="0" title="'.$data['name'].'" style="background-image: url(/inc/shop/images/'.$data['thumb_image'].');" /></a></th>
</tr>
<tr>
<td><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$data['url_key'].'" title="'.$data['name'].'">'.$shortName.'</a> '.$price.$outOfStock.'</td>
</tr>
</table>';
}
$products .= '</div>';
$mainhtml .= stripslashes($products);
//include this add-ons's overwrite css file from the template being used, if there is one
$t = settings('template');
if(file_exists('templates/'.$t['template'].'/addons/shop.css'))
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="/templates/'.$t['template'].'/addons/shop.css" /></head>', $mainhtml);
}
else
{
$mainhtml = str_replace("</head>", '<link rel="stylesheet" type="text/css" href="//www.freesites.com.au/addons/shop.css" /></head>', $mainhtml);
}
//end
?>