영카트 리스트

영카트 리스트

QA

영카트 리스트

본문

안녕하세요 고수님들 

영카트 리스트 페이지에서 코드 하나만 클래스명을 다르게 주고 싶은데 어떻게 해야할까요??

 


<ul class="sct sct_10">
    <?php
    $i = 0;
    $this->view_star = (method_exists($this, 'view_star')) ? $this->view_star : true;
    foreach((array) $list as $row){
        if(empty($row)) continue;
        $item_link_href = shop_item_url($row['it_id']);     // 상품링크
        $star_score = $row['it_use_avg'] ? (int) get_star($row['it_use_avg']) : '';     //사용자후기 평균별점
        $list_mod = $this->list_mod;    // 분류관리에서 1줄당 이미지 수 값 또는 파일에서 지정한 가로 수
        $is_soldout = is_soldout($row['it_id'], true);   // 품절인지 체크
        $i++;   // 변수 i 를 증가
    ?>
        <li class="sct_li" data-css="nocss" style="height:auto">
            <div class="sct_img">
                <a href="<?php echo $item_link_href?>"><?php echo get_it_image($row['it_id'], $this->img_width, $this->img_height, '', '', stripslashes($row['it_name']))."\n"; ?></a>
                <?php if (!$is_soldout ) { // 품절 상태가 아니면 출력합니다. ?>
                <div class="sct_btn list-10-btn">
                    <button type="button" class="btn_cart sct_cart" data-it_id="<?php echo $row['it_id']?>"><i class="fa fa-shopping-cart" aria-hidden="true"></i> 장바구니</button>
                </div>
                <?php } ?>
                <div class="cart-layer"></div>
                <?php if ($is_soldout) { ?>
                    <span class="shop_icon_soldout"><span class="soldout_txt">SOLD OUT</span></span>
                <?php } ?>
            </div>
            <div class="sct_ct_wrap">
                <div class="sct_txt"><a href="<?php echo $item_link_href ?>"><?php echo stripslashes($row['it_name']) ?></a></div>
                <div class="sct_bottom">
                    <?php if ($this->view_it_cust_price || $this->view_it_price) { ?>
                    <div class="sct_cost">
                        <?php if ($this->view_it_price) { echo display_price(get_price($row), $row['it_tel_inq'])."\n"; } ?>
                        <?php if ($this->view_it_cust_price && $row['it_cust_price']) { echo "<span class=\"sct_dict\">".display_price($row['it_cust_price'])."</span>\n"; } ?>
                    </div>
                    <?php } ?>
                    <!-- 위시리스트 + 공유 버튼 시작 -->
                    <div class="sct_op_btn">
                        <button type="button" class="btn_wish" data-it_id="<?php echo $row['it_id'];?>"><i class="fal fa-heart"></i></button>
                        <!--<button type="button" class="btn_share"><i class="fal fa-share-alt" aria-hidden="true"></i></button>-->
                    
                        <div class="sct_sns_wrap">
                            <?php
                            if ($this->view_sns) {
                                $sns_top = $this->img_height + 10;
                                $sns_url  = $item_link_href;
                                $sns_title = get_text($row['it_name']).' | '.get_text($config['cf_title']);
                                echo "<div class=\"sct_sns\">";
                                echo "<h3>SNS 공유</h3>";
                                echo get_sns_share_link('facebook', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/facebook.png');
                                echo get_sns_share_link('twitter', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/twitter.png');
                                echo get_sns_share_link('googleplus', $sns_url, $sns_title, G5_SHOP_SKIN_URL.'/img/gplus.png');
                                echo "<button type=\"button\" class=\"sct_sns_cls\"><span class=\"sound_only\">닫기</span><i class=\"far fa-times\" aria-hidden=\"true\"></i></button>";
                                echo "</div>\n";
                            }
                            ?>
                            <div class="sct_sns_bg"></div>
                        </div>
                    </div>
                    <!--<div class="sit_icon_li"><?php echo item_icon($row) ?></div>-->
                </div>
                <div class="sct_basic"><?php echo stripslashes($row['it_basic']) ?></div>
            </div>
        </li>
    <?php } ?>
</ul>

이 질문에 댓글 쓰기 :

답변 2

질문이 모호합니다.

 

질문에서 말하는 클래스는 어떤 클래스를 대치할지에 대한 기준이 없고

 

어떤상황일때 A클래스를 B클래스로 바꾸고 싶다 가 있어야 할것같은데

그것도 없네요

 

리스트는 기본적으로 반복문에 의해서 순환하는 문장입니다.

 

foreach( (array) $list => $row) {

로 시작하는 부분부터

대응되는

가 닫힐때까지 반복하기때문에

 

어떤 조건일때가 나와야 변경이 가능합니다.

 

예를들어

가격의 컬러를

특정상품코드 에서 변환하겠다.라면


 

 <?php if ($this->view_it_cust_price || $this->view_it_price) { ?>
                    <?php 
                     // 상품코드 : 11000111 일때 하위의 컬러가 적용된 클래스를 변경하겠다 라는 의지라면
                     // 임의의 클래스명 sct_cost_new 라고 지정하고
                     if ($row['it_id'] == '11000111') {
                         $sct_class = "sct_cost_new";
                     }
                     else {
                          $sct_class = "sct_cost";
                     }
                     ?>
                    <!-- <div class="sct_cost">  --><!--// 기존은 이렇게 되어있던 코드를 주석 : 확인후 삭제해도됩니다. -->
                    <div class="<?php echo $sct_class;?>">   <!--// 이렇게 변경합니다. -->
                          <?php if ($this->view_it_price) { echo display_price(get_price($row), $row['it_tel_inq'])."\n"; } ?>
                        <?php if ($this->view_it_cust_price && $row['it_cust_price']) { echo "<span class=\"sct_dict\">".display_price($row['it_cust_price'])."</span>\n"; } ?>
                    </div>
                    <?php } ?>

 

 

 

상품코드가 1631261027 일경우 클라스명을 추가해서 리스트에서는 안보이게 하고 싶습니다
광고는 진행해야해서 판매를 하고 리스트에서만 노출이 안되게 하려면 어떻게 해야할까요?

sql을 수정해서
해당 상품을 빼고 select 하도록 where 구문을 수정하는 방법도 있겠습니다.
또는,
상품 리스트 스킨에서
loop 돌 때, 해당 상품은 skip하도록 할 수 도 있구요.


리스트에서는 출력을 안하게 하는게 방법이면


 foreach((array) $list as $row){
        if(empty($row)) continue;
        if ($row['it_id'] == '1631261027') continue;  // 이걸 추가

이렇게 하시면될것 같네요

list.php 에서는 안보이고
item.php?it_id=1631261027
로 접근하면 보입니다.

코드하나만 class를 다르게 주고 싶은 기준이 있을텐데

 

$class = (조건문)?"반영할 class":"sct_li";

 

<li class="<?=$class?>" data-css="nocss" style="height:auto">

 

이런식으로 조건문을 기준으로 class를 변경해 주시면 됩니다.

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

회원로그인

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