영카트 2차 카테고리에서 전체 카테고리

영카트 2차 카테고리에서 전체 카테고리

QA

영카트 2차 카테고리에서 전체 카테고리

본문

https://sir.kr/yc5_tip/778

 

해당 글 보고 2차 카테고리로 고정은 했는데

 

가장 앞에 전체 카테고리가 나오게 하려면 어떤 함수를 추가해야하나요 ?

 


<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$str = '';
$exists = false;
$depth2_ca_id = substr($ca_id, 0, 2);
$sql = " select ca_id, ca_name from {$g5['g5_shop_category_table']} where ca_id like '${depth2_ca_id}%' and length(ca_id) = 4 and ca_use = '1' order by ca_order, ca_id ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result)) {
    if (preg_match("/^{$row['ca_id']}/", $ca_id))
        $sct_ct_here = 'sct_ct_here';
    else
        $sct_ct_here = '';
    $str .= '<li><a href="./list.php?ca_id='.$row['ca_id'].'" class="'.$sct_ct_here.'">'.$row['ca_name'].'</a></li>';
    $exists = true;
}
if ($exists) {
    // add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
    add_stylesheet('<link rel="stylesheet" href="'.G5_SHOP_CSS_URL.'/style.css">', 0);
?>
<!-- 상품분류 3 시작 { -->
<aside id="sct_ct_3" class="sct_ct">
    <h2>현재 상품 분류와 관련된 분류</h2>
    <ul>
        <?php echo $str; ?>
    </ul>
</aside>
<!-- } 상품분류 3 끝 -->
<?php } ?>

이 질문에 댓글 쓰기 :

답변 1


$exists = false;
$depth2_ca_id = substr($ca_id, 0, 2);
$str = '<li><a href="./list.php?ca_id='.$depth2_ca_id.'">전체</a></li>';

우와 바로 해결했습니다! 감사합니다♡
카테고리가 선택될 경우 .sct_ct_here라는 클래스가 붙는데 혹시 전체 상태일때도 해당 클래스가 오게 하려면 어떻게 해야할까요..??

if ($ca_id == $depth2_ca_id)
        $sct_ct_here = 'sct_ct_here';
    else
        $sct_ct_here = '';

$str = '<li><a href="./list.php?ca_id='.$depth2_ca_id.'" class="'.$sct_ct_here.'">전체</a></li>';

답변을 작성하시기 전에 로그인 해주세요.
전체 831
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT