<?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
$catBlurb = '';
if($parent > 0)
{
$meta = $mysql->get_array($mysql->query("blurb,meta_title,meta_keywords,meta_desc", "fs_shop_cats", "ID = $cat LIMIT 1"));
$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'];
$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 content from the shop CMS page
$showH1 = true;
if(!isset($_GET['junk']))
{
$shopcontent = $mysql->get_array($mysql->query("content", $mysql->perfix."pages", "ID = {$s['shop_page']} LIMIT 1"));
$cats = stripslashes($shopcontent['content']);
$showH1 = false;
}
$cats .= ($showH1) ? '<h1>'.$t.'</h1>' : '';
$cats .= '<p id="shopCrumbs">'.$crumbs.'</p>';
//show cat list
$size = $site->shop_settings('catimage_height,catimage_width');
$cats .= $catBlurb.'<div id="prodlist">';
$query = $mysql->query("ID,name,image,url_key", "fs_shop_cats", "sub = $parent AND `live` = 'y' ORDER BY `order` ASC");
while($data = $mysql->get_array($query))
{
$dispName = (strlen($data['name']) > 35) ? substr($data['name'], 0, 35).'...' : $data['name'];
$cats .= '<table border="0" cellspacing="0" cellpadding="0" class="catlist" 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" style="background-image:url(/inc/shop/images/'.$data['image'].');" /></a></th></tr><tr><td><a href="/'.$s['shop_page'].'/'.$seo_pageTitle.'/'.$data['url_key'].'" title="'.$data['name'].'">'.$dispName.'</a></td></tr></table>';
}
$cats .= '</div>';
$mainhtml .= stripslashes($cats);
//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
?>