영카트 제품카테고리 메뉴 3차분류 나오게 하는법
본문
위 처럼 2차 분류를 옥외용 광 패치코드에 넣었는데
메뉴에는 옥외용 광 패치코드라는 중분류가 반영이 안되고
그냥 상품명만 노출이 됩니다. (상세페이지에는 중분류 타이틀이 노출 됨)
메뉴에도 중분류가 나오고 그 안으로 상품들이 들어가 있게 수정이될까요?
아래에 메뉴 부분 소스랑, 아코디언 메뉴 스크립트 적어드립니다.
<?php
$sql = "SELECT it_id, ca_id, ca_id2, it_name, it_en_name FROM g5_shop_item WHERE it_use=1 ORDER BY ca_id ASC, ca_id2 ASC";
$result = sql_query($sql);
?>
<ul class="topnav">
<?php
for ($i=0; $row=sql_fetch_array($result); $i++) {
if(!$it_id && $i === 0) {
$it_id = $row['it_id'];
$view_ca_id = ($view_ca_id) ? $view_ca_id : '';
}
if($temp_ca_id != substr($row['ca_id'], 0, 2)) {
$no = 0;
$temp_ca_id = substr($row['ca_id'], 0, 2);
$ca_row = sql_fetch("SELECT ca_name, ca_en_name FROM g5_shop_category WHERE ca_use=1 AND ca_id='{$temp_ca_id}'");
$_ca_name = ($_SESSION['site'] == 'e') ? $ca_row['ca_en_name'] : $ca_row['ca_name'];
if($i !== 0 && $no === 0) {
echo '</ul>'.PHP_EOL;
echo '</li>'.PHP_EOL;
}
echo '<li>'.PHP_EOL;
echo '<a href="#"><strong>'.$_ca_name.'</strong></a>'.PHP_EOL;
}
$_it_name = ($_SESSION['site'] == 'e') ? $row['it_en_name'] : $row['it_name'];
if($no == 0) {
if($view_ca_id == $temp_ca_id) {
echo '<ul class="sec" style="display:block">'.PHP_EOL;
}
else {
echo '<ul class="sec">'.PHP_EOL;
}
}
echo '<li><a href="/yc5/shop/product.php?ca_name='.$_ca_name.'&view_ca_id='.$temp_ca_id.'&it_id='.$row['it_id'].'">'.$_it_name.'</a></li>'.PHP_EOL;
$no++;
}
?>
</ul>
<p style="padding-top:15px;">
<a href="/catalog.pdf" style=" font-size:16px; font-weight:600; color:#5F67AE;font-family:Nanum Gothic, 나눔고딕" target="_blank"><?php echo ($_SESSION['site'] == 'e') ? 'Catalog' : '카다로그' ?></a>
</p>
<p><img src="/img/service.gif" align="bottom"></p>
</div>
</p></p>
</td>
<?php
$sql = " select a.*, b.ca_name, b.ca_en_name, b.ca_use from {$g5['g5_shop_item_table']} a, {$g5['g5_shop_category_table']} b where a.it_id = '$it_id' and a.ca_id = b.ca_id ";
$it = sql_fetch($sql);
?>
<td width="734" valign="top"><table border="0" align="center" cellpadding="0" cellspacing="0" height="166">
<tr>
<td width="364" height="43" background="title_a1.gif" style="padding-left:15px; font-weight:bold; font-size:18px; font-family:'맑은고딕'">
<?php
if ($_SESSION['site'] == 'e')
echo ($it['ca_en_name']) ? $it['ca_en_name']:$it['ca_name'];
else
echo $it['ca_name']
?>
</td>
<td width="370" height="66" valign="middle" bgcolor="#ededed">
<p align="right" class="style1"><span style="font-size:9pt;"><span style="font-size:9pt;"><a href="/index.html">HOME</a><span style="font-size:9pt;"> <img src="http://skinc.co.kr/img/e_img/icon2.gif"> </span><span style="font-size:9pt;"><span style="font-size:9pt;"><span style="font-size:9pt;"> </span><a href="/kp1-1.html"><?=($_SESSION['site'] == 'e') ? 'Products':'제품소개'?></a><span style="font-size:9pt;"><img src="http://skinc.co.kr/img/e_img/icon2.gif"></span></span></span>
<?
if ($_SESSION['site'] == 'e')
echo ($it['it_en_name']) ? $it['it_en_name']:$it['it_name'];
else
echo $it['it_name']
?>
</td>
</tr>
<tr>
<td colspan="2" height="25" align="center">
<?
$ca_2ndinfo = get_ca_name($it['ca_id2']);
if ($_SESSION['site'] == 'e')
{
if ($ca_2ndinfo['ca_en_name'])
echo "<div style='text-align:left;padding-left:10px;font-size:14px;font-weight:bold; margin-bottom:20px; font-family:'맑은고딕''>{$ca_2ndinfo['ca_en_name']}</div>";
else
echo "<div style='text-align:left;padding-left:10px;font-size:14px;font-weight:bold; margin-bottom:20px;font-family:'맑은고딕''>{$ca_2ndinfo['ca_name']}</div>";
}
else
echo "<div style='text-align:left;padding-left:10px;font-size:14px;font-weight:bold; margin-bottom:20px;font-family:'맑은고딕''>{$ca_2ndinfo['ca_name']}</div>";
$ca_list = get_ca_goods($it['ca_id'], $it['ca_id2']);
echo '<span class="style5" style="display:inline-block; margin-bottom:20px; font-size:16px"><strong>[</strong>';
for ($i=1; $row=sql_fetch_array($ca_list); $i++)
{
if ($i > 1)
echo " <strong>|</strong> ";
$ca_1stinfo = get_ca_name($row['ca_id']);
if ( $_SESSION['site'] == "e")
{
$t_caname = ($ca_1stinfo['ca_en_name']) ? $ca_1stinfo['ca_en_name']:$ca_1stinfo['ca_name'];
$t_itname = ($row['it_en_name']) ? $row['it_en_name']:$row['it_name'];
echo "<a href='/yc5/shop/product.php?ca_name={$t_caname}&it_id={$row['it_id']}'>{$t_itname}</a>";
}
else
echo "<a href='/yc5/shop/product.php?ca_name={$ca_1stinfo['ca_name']}&it_id={$row['it_id']}'>{$row['it_name']}</a>";
if ($it_id == $row['it_id'])
{
if ( $_SESSION['site'] == "e")
$sel_it_name = $i.". ".$t_itname;
else
$sel_it_name = $i.". ".$row['it_name'];
}
}
echo "<strong>]</strong></span>";
echo "<div style='text-align:left;padding-left:10px;font-size:14px;font-weight:bold;'><strong>{$sel_it_name} </strong></div>";
$img_cnt = 0;
for($k = 1; $k <= 10; $k++)
{
$it_img = G5_DATA_PATH.'/item/'.$it['it_img'.$k];
if(is_file($it_img) && $it['it_img'.$k])
{
$img_cnt++;
}
}
?>
<div class="Wrap_pro" style="padding-top:20px;">
<div id="product" style="<?=($img_cnt > 8) ? 'height:360px;':''?>">
<div id="window"><img src="<?php echo G5_DATA_URL; ?>/item/<?php echo $it['it_img1']; ?>" alt="" width=439 height=286 alt="" /></div>
<ul id="nav">
<?php
for($k = 1; $k <= 10; $k++)
{
$it_img = G5_DATA_PATH.'/item/'.$it['it_img'.$k];
if(is_file($it_img) && $it['it_img'.$k])
{
$size = @getimagesize($it_img);
$thumb = get_it_thumbnail($it['it_img'.$k], 25, 25);
?>
<li><a href="<?php echo G5_DATA_URL; ?>/item/<?php echo $it['it_img'.$k]; ?>" class="<?=($k == 1)? 'active':''?>"><img src="<?php echo G5_DATA_URL; ?>/item/<?php echo $it['it_img'.$k]; ?>" alt="" width=108 height=70/></a></li>
<?php
}
else
{
?>
<?php
}
}
?>
</ul>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#nav a').mouseover(function(e){
e.preventDefault();
$('#nav a').removeClass('active');
$(this).addClass('active');
img_url = $(this).attr('href');
$('#window img').attr('src',img_url);
});
})
</script>
<p>
<?php
if ($_SESSION['site'] == "e")
//echo nl2br($it['it_en_explan']);
echo $it['it_en_explan'];
else
//echo nl2br($it['it_explan']);
echo $it['it_explan'];
/*
* jQuery UI Multilevel Accordion v.1
*
* Copyright (c) 2011 Pieter Pareit
*
* http://www.scriptbreaker.com
*
*/
//plugin definition
(function($){
$.fn.extend({
//pass the options variable to the function
accordion: function(options) {
var defaults = {
accordion: 'true',
speed: 300,
closedSign: '[+]',
openedSign: '[-]'
};
// Extend our default options with those provided.
var opts = $.extend(defaults, options);
//Assign current element to variable, in this case is UL element
var $this = $(this);
//add a mark [+] to a multilevel menu
$this.find("li").each(function() {
if($(this).find("ul").size() != 0){
//add the multilevel sign next to the link
$(this).find("a:first").append("<span>"+ opts.closedSign +"</span>");
//avoid jumping to the top of the page when the href is an #
if($(this).find("a:first").attr('href') == "#"){
$(this).find("a:first").click(function(){return false;});
}
}
});
//open active level
$this.find("li.active").each(function() {
$(this).parents("ul").slideDown(opts.speed);
$(this).parents("ul").parent("li").find("span:first").html(opts.openedSign);
});
$this.find("li a").click(function() {
if($(this).parent().find("ul").size() != 0){
if(opts.accordion){
//Do nothing when the list is open
if(!$(this).parent().find("ul").is(':visible')){
parents = $(this).parent().parents("ul");
visible = $this.find("ul:visible");
visible.each(function(visibleIndex){
var close = true;
parents.each(function(parentIndex){
if(parents[parentIndex] == visible[visibleIndex]){
close = false;
return false;
}
});
if(close){
if($(this).parent().find("ul") != visible[visibleIndex]){
$(visible[visibleIndex]).slideUp(opts.speed, function(){
$(this).parent("li").find("span:first").html(opts.closedSign);
});
}
}
});
}
}
if($(this).parent().find("ul:first").is(":visible")){
$(this).parent().find("ul:first").slideUp(opts.speed, function(){
$(this).parent("li").find("span:first").delay(opts.speed).html(opts.closedSign);
});
}else{
$(this).parent().find("ul:first").slideDown(opts.speed, function(){
$(this).parent("li").find("span:first").delay(opts.speed).html(opts.openedSign);
});
}
}
});
}
});
})(jQuery);
답변 1
기획자체를 바꾸셔야될거 같다고 생각합니다.
왼쪽메뉴는 상품을 기준으로 나열하는 기획으로
지금 원하시는것은 3차 분류이시기에
분류기준으로 메뉴를 만드셔야될것으로 판단됩니다.
지금 상품기준 메뉴구성으로 아코디언을 만드시기엔 까다로워 보입니다.
조건을 추가하시거나 쿼리를 더 만드셔야될거 같아요
답변을 작성하시기 전에 로그인 해주세요.