영카트 2차 카테고리에서 전체 카테고리 채택완료

https://sir.kr/yc5_tip/778

 

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

 

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

 

Copy
<?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개

채택된 답변
+20 포인트

Copy
$exists = false;
$depth2_ca_id = substr($ca_id, 0, 2);

$str = '<li><a href="./list.php?ca_id='.$depth2_ca_id.'">전체</a></li>';
로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

우와 바로 해결했습니다! 감사합니다♡
카테고리가 선택될 경우 .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>';
정말 감사합니다!! ㅠ

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고