상품 2차분류 active 클래스 주기

상품 2차분류 active 클래스 주기

QA

상품 2차분류 active 클래스 주기

본문

list.10.skin.php에서 listcategory3.skin.php 불러와 2차분류를 불러왔습니다!

여기서 한 분류 클릭 시 class active를 부여하고싶은데 이래저래 변형해봐도 먹지를 않아서 질문드립니다!

php 정말 힘드네요.. 

 

listcategory3.skin.php

 


<?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="'.shop_category_url($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_SKIN_URL.'/style.css">', 0);
?>
 
<!-- 상품분류 3 시작 { -->
<aside id="sct_ct_3" class="sct_ct">
    <h2>현재 상품 분류와 관련된 분류</h2>
    <ul>
        <?php echo $str; ?>
    </ul>
</aside>
<!-- } 상품분류 3 끝 -->
 
<?php }

이 질문에 댓글 쓰기 :

답변 3

그러면 URL 로 파라미터를 넘기면되잖아요.

<a href="'.shop_category_url($row['ca_id']).'&categoryid='.$row['ca_id'].'"

 

이렇게 하면 URL 뒤에 categoryid 파라미터가 날아갈테고

 

if($_GET['categoryid'] == '$row['ca_id']') echo 'active';

 

이렇게 GET 으로 받아와서 현재 ca_id 와 일치하면 active 클래스 넣으면 될것 같은데요?

GET으로 받아오는게 맞았네요 감사합니다.


while ($row=sql_fetch_array($result)) {
    if ($_GET['ca_id'] == $row['ca_id'])
        $sct_ct_here = 'active';
    else
        $sct_ct_here = '';
    $str .= '<li><a href="'.shop_category_url($row['ca_id']).'" class="'.$sct_ct_here.'">'.$row['ca_name'].'</a></li>';
    $exists = true;
}

js 도 빠져있고 설명 네줄로는 의도하시는 바를 모르겠습니다.

 '<li><a href="'.shop_category_url($row['ca_id']).'" class="'.$sct_ct_here.'">'.$row['ca_name'].'</a></li>' 

2차분류를 불러오는 구문인데 여기서 현재 들어가있는 분류페이지의 링크에 active를 주고싶습니다.
js는 없고 기본인 상태입니다.


                $sql = " select count(*) as cnt from {$g5['board_table']} where gr_id = 'GallType' order by bo_subject "; // 게시판 중에 gr_id 가 GallType 인 게시판들의 개수를 불러옴
                $row = sql_fetch($sql);
                $sql = " select bo_table, bo_subject from {$g5['board_table']} where gr_id = 'GallType' order by gr_id "; // 그룹이 GallType인 게시판들의 bo_table, bo_subject 를 가져옴
                $result = sql_query($sql);
                $str = '';
                for($i=0;$row=sql_fetch_array($result);$i++){ // for문으로 카테고리를 생성
                    $str .= '<li><a href="/bbs/board.php?bo_table='.$row['bo_table'].'" title="'.$row['bo_subject'].'"';
                    if( $row['bo_table'] === $bo_table )
                    $str .= 'class="active"';
                    $str .= '>'.$row['bo_subject'].'</a></li>';
                }
                echo $str;


예를들어 이건 게시판 그룹 리스트를 가져와서 들어가있는 리스트 게시판 텍스트에 active를 준 구문입니다! 이것과 같게 상품 분류에도 적용시키고싶은데 잘안되서요

위에 보시면 분류 클릭시 라고 하셨는데

addClass 를 먹여도 클릭하면 URL 이동이 되어 어차피 초기화 될텐데요?

정확하게 뭘 하시고 싶은건지 말씀해주세요.

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

회원로그인

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