2차카테고리 리스트 페이지에서 2차카테고리 전체목록 보이게 하는 방법

2차카테고리 리스트 페이지에서 2차카테고리 전체목록 보이게 하는 방법

QA

2차카테고리 리스트 페이지에서 2차카테고리 전체목록 보이게 하는 방법

답변 1

본문

기본 소스에서 1차 카테고리가 상의 

2차 카테고리가 반팔 티셔츠, 긴팔티셔츠, 반팔셔츠 이렇게 있다고 가정했을 때 

 

1차 카테고리 상단에 

2차카테고리가 전체적으로 뿌려지는데

반팔티셔츠를 눌러 리스트페이지가 변동되었을 때도 유동적으로 다른 2차 카테고리를 클릭할 수 있도록

목록이 나오게 하려면 어떻게 해야하나요?

 


<?php
include_once('./_common.php');
 
$ca_id = isset($_REQUEST['ca_id']) ? safe_replace_regex($_REQUEST['ca_id'], 'ca_id') : '';
$skin = isset($_REQUEST['skin']) ? safe_replace_regex($_REQUEST['skin'], 'skin') : '';
 
// 상품 리스트에서 다른 필드로 정렬을 하려면 아래의 배열 코드에서 해당 필드를 추가하세요.
if( isset($sort) && ! in_array($sort, array('it_name', 'it_sum_qty', 'it_price', 'it_use_avg', 'it_use_cnt', 'it_update_time')) ){
    $sort='';
}
 
if (G5_IS_MOBILE) {
    include_once(G5_MSHOP_PATH.'/list.php');
    return;
}
 
$sql = " select * from {$g5['g5_shop_category_table']} where ca_id = '$ca_id' and ca_use = '1'  ";
$ca = sql_fetch($sql);
if (! (isset($ca['ca_id']) && $ca['ca_id']))
    alert('등록된 분류가 없습니다.');
 
// 테마미리보기 스킨 등의 변수 재설정
if(defined('_THEME_PREVIEW_') && _THEME_PREVIEW_ === true) {
    $ca['ca_skin']       = (isset($tconfig['ca_skin']) && $tconfig['ca_skin']) ? $tconfig['ca_skin'] : $ca['ca_skin'];
    $ca['ca_img_width']  = (isset($tconfig['ca_img_width']) && $tconfig['ca_img_width']) ? $tconfig['ca_img_width'] : $ca['ca_img_width'];
    $ca['ca_img_height'] = (isset($tconfig['ca_img_height']) && $tconfig['ca_img_height']) ? $tconfig['ca_img_height'] : $ca['ca_img_height'];
    $ca['ca_list_mod']   = (isset($tconfig['ca_list_mod']) && $tconfig['ca_list_mod']) ? $tconfig['ca_list_mod'] : $ca['ca_list_mod'];
    $ca['ca_list_row']   = (isset($tconfig['ca_list_row']) && $tconfig['ca_list_row']) ? $tconfig['ca_list_row'] : $ca['ca_list_row'];
}
 
// 본인인증, 성인인증체크
if(!$is_admin && $config['cf_cert_use']) {
    $msg = shop_member_cert_check($ca_id, 'list');
    if($msg)
        alert($msg, G5_SHOP_URL);
}
 
$g5['title'] = $ca['ca_name'].' 상품리스트';
 
if ($ca['ca_include_head'] && is_include_path_check($ca['ca_include_head']))
    @include_once($ca['ca_include_head']);
else
    include_once(G5_SHOP_PATH.'/_head.php');
 
// 스킨경로
$skin_dir = G5_SHOP_SKIN_PATH;
 
if($ca['ca_skin_dir']) {
    if(preg_match('#^theme/(.+)$#', $ca['ca_skin_dir'], $match))
        $skin_dir = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/shop/'.$match[1];
    else
        $skin_dir = G5_PATH.'/'.G5_SKIN_DIR.'/shop/'.$ca['ca_skin_dir'];
 
    if(is_dir($skin_dir)) {
        $skin_file = $skin_dir.'/'.$ca['ca_skin'];
 
        if(!is_file($skin_file))
            $skin_dir = G5_SHOP_SKIN_PATH;
    } else {
        $skin_dir = G5_SHOP_SKIN_PATH;
    }
}
 
define('G5_SHOP_CSS_URL', str_replace(G5_PATH, G5_URL, $skin_dir));
echo '<div>';
$nav_skin = $skin_dir.'/navigation.skin.php';
    if(!is_file($nav_skin))
        $nav_skin = G5_SHOP_SKIN_PATH.'/navigation.skin.php';
    include $nav_skin;
    // 상단 HTML
    //echo '<div id="sct_hhtml">'.conv_content($ca['ca_head_html'], 1).'</div>';
 
    $cate_skin = $skin_dir.'/listcategory.skin.php'; // 카테고리 출력부분
    if(!is_file($cate_skin))
        $cate_skin = G5_SHOP_SKIN_PATH.'/listcategory.skin.php';
    include $cate_skin;
//echo '<h1>'.$ca['ca_name'].'</h1>';
?>
 
<!-- 히트상품 시작 { -->
    <div class="cat_best">
    <h2>베스트 상품</h2>
    <section class="sct_wrap">
            <?php
                           
            //---------------- 여기부터
            $skin_file = G5_SHOP_SKIN_PATH .'/list.10.skin.php'; //스킨명(기존 것을 사용하거나 새로이 만들거나)
            $item_mod = 5; //한줄당 갯수
            $item_rows = 1; //줄 수
            $item_width= 380; //이미지 가로
            $item_height = 380; //이미지 세로
       
            $list = new item_list($skin_file, $item_mod , $item_rows , $item_width, $item_height);
            $list->set_type(2); // 히트상품유형
            //---------- 여기까지
       
            $list->set_category($ca['ca_id'], 1);
            $list->set_category($ca['ca_id'], 2);
            $list->set_category($ca['ca_id'], 3);
            $list->set_view('it_img', true);
            $list->set_view('it_id', false);
            $list->set_view('it_name', true);
            $list->set_view('it_basic', true);
            $list->set_view('it_cust_price', true);
            $list->set_view('it_price', true);
            $list->set_view('it_icon', false);
            $list->set_view('sns', false);
            echo $list->run();
                ?>
    </section>
</div>
<!-- } 히트상품 끝 -->
<?php
if ($is_admin)
    echo '<div class="sct_admin"><a href="'.G5_ADMIN_URL.'/shop_admin/categoryform.php?w=u&ca_id='.$ca_id.'" class="btn_admin btn"><span class="sound_only">분류 관리</span><i class="fa fa-cog fa-spin fa-fw"></i></a></div>';
 
    echo '<div id="sct_sortlst"><i class="xi-tune"></i>';
 
    //상품 보기 타입 변경 버튼
    $sub_skin = $skin_dir.'/list.sub.skin.php';
    if(!is_file($sub_skin))
        $sub_skin = G5_SHOP_SKIN_PATH.'/list.sub.skin.php';
    include $sub_skin;
    $sort_skin = $skin_dir.'/list.sort.skin.php';
    if(!is_file($sort_skin))
        $sort_skin = G5_SHOP_SKIN_PATH.'/list.sort.skin.php';
    include $sort_skin;
    echo '</div>';
?>
 
<script>
var itemlist_ca_id = "<?php echo $ca_id; ?>";
</script>
<script src="<?php echo G5_JS_URL; ?>/shop.list.js"></script>
<?php if($default['de_type1_list_use']) { ?>
<?php } ?>
<!-- 상품 목록 시작 { -->
<div id="sct">
 
    <?php
   
 
    // 상품 출력순서가 있다면
    if ($sort != "")
        $order_by = $sort.' '.$sortodr.' , it_order, it_id desc';
    else
        $order_by = 'it_order, it_id desc';
 
    $error = '<p class="sct_noitem">등록된 상품이 없습니다.</p>';
 
    // 리스트 스킨
    $skin_file = is_include_path_check($skin_dir.'/'.$ca['ca_skin']) ? $skin_dir.'/'.$ca['ca_skin'] : $skin_dir.'/list.10.skin.php';
 
    if (file_exists($skin_file)) {
 
        // 총몇개 = 한줄에 몇개 * 몇줄
        $row =
        $items = $ca['ca_list_mod'] * $ca['ca_list_row'];
       
        // 페이지가 없으면 첫 페이지 (1 페이지)
        if ($page < 1) $page = 1;
        // 시작 레코드 구함
        $from_record = ($page - 1) * $items;
 
        $list = new item_list($skin_file, $ca['ca_list_mod'], $ca['ca_list_row'], $ca['ca_img_width'], $ca['ca_img_height']);
        $list->set_category($ca['ca_id'], 1);
        $list->set_category($ca['ca_id'], 2);
        $list->set_category($ca['ca_id'], 3);
        $list->set_is_page(true);
        $list->set_order_by($order_by);
        $list->set_from_record($from_record);
        $list->set_view('it_img', true);
        $list->set_view('it_id', false);
        $list->set_view('it_name', true);
        $list->set_view('it_basic', true);
        $list->set_view('it_cust_price', true);
        $list->set_view('it_price', true);
        $list->set_view('it_icon', true);
        $list->set_view('sns', true);
        echo $list->run();
 
        // where 된 전체 상품수
        $total_count = $list->total_count;
        // 전체 페이지 계산
        $total_page  = ceil($total_count / $items);
    }
    else
    {
        echo '<div class="sct_nofile">'.str_replace(G5_PATH.'/', '', $skin_file).' 파일을 찾을 수 없습니다.<br>관리자에게 알려주시면 감사하겠습니다.</div>';
    }
 
    $qstr1 = 'ca_id='.$ca_id;
    $qstr1 .='&sort='.$sort.'&sortodr='.$sortodr;
    echo get_paging($config['cf_write_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'].'?'.$qstr1.'&page=');
 
    // 하단 HTML
    //echo '<div id="sct_thtml">'.conv_content($ca['ca_tail_html'], 1).'</div>';
 
?>
</div>
<!-- } 상품 목록 끝 -->
</div>
<?php
if ($ca['ca_include_tail'] && is_include_path_check($ca['ca_include_tail']))
    @include_once($ca['ca_include_tail']);
else
    include_once(G5_SHOP_PATH.'/_tail.php');
 
echo "\n<!-- {$ca['ca_skin']} -->\n";
 

 

/shop/list.php

이 질문에 댓글 쓰기 :

답변 1

/theme/basic/skin/shop/basic/listcategory.skin.php 파일에 아래 소스를 수정해보세요


$ca_id_len = strlen($ca_id);
if($ca_id_len==2) {
    $len2 = $ca_id_len + 2;
    $len4 = $ca_id_len + 4;
} else {
    $len2 = $ca_id_len;
    $len4 = $ca_id_len + 2;
}

답변 감사합니다! 적용해보니 나오기는 하는데 누른 2차 카테고리명? 만 노출이되더라고요. 저는 해당 2차 카테고리 뿐만 아니라 그와 같은 1차에 해당하는 2차 전체카테고리를 출력하고싶은데 가능할까요?

$ca_id2 부분 수정해주세요.


$ca_id_len = strlen($ca_id);
if($ca_id_len==2) {
    $len2 = $ca_id_len + 2;
    $len4 = $ca_id_len + 4;
    $ca_id2 = $ca_id;
} else {
    $len2 = $ca_id_len;
    $len4 = $ca_id_len + 2;
    $ca_id2 = substr($ca_id,0,2);
}

$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '$ca_id2%' and length(ca_id) = $len2 and ca_use = '1' order by ca_order, ca_id ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result)) {

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 178
© SIRSOFT
현재 페이지 제일 처음으로