채택완료

상품 검색 페이지 검색 결과 관련 문의

2018-01-30 (화) 17:57:18 2,505

영카트5 버전 쓰고 있습니다.

search.php 로 접속 했을때 기본적으로 전 상품이 검색되어져 나오는데,

첫 화면에서는 아무것도 안나오게, 즉

검색조건을 주었을 때만 결과를 나오게 하려면 어디를 수정해야 할지 모르겠습니다.

|

답변 3개

채택된 답변
+20 포인트

search.php 의 다음 코드 부분을 다음과 같이 수정하면 될 듯 합니다.

Copy
$sql_where = " where " . implode(" and ", $where);

->

Copy
$sql_where = " where " . implode(" and ", $where);

if ($_SERVER['QUERY_STRING'] == "") // 검색 조건을 주지 않은 경우에는
    $sql_where = " where 0 ";

덕분에 해결했습니다. 깊은 감사 드려요.

검색시 count($where) 가 1이상 나오는 거을 이용하여 

skin/shop/basic/ 에 shop.skin.php 를 이용하시면 

56라인에 

<?php if(count($where)>1){?>
    <!-- 검색된 분류 시작 { -->    
    <div id="ssch_cate">
        <ul>
        <?php
        $total_cnt = 0;
        foreach( $categorys as $row ){
            if( empty($row) ) continue;
            echo "<li><a href=\"#\" onclick=\"set_ca_id('{$row['ca_id']}'); return false;\">{$row['ca_name']} (".$row['cnt'].")</a></li>\n";
            $total_cnt += $row['cnt'];
        }
        echo '<li><a href="#" onclick="set_ca_id(\'\'); return false;">전체분류 <span>('.$total_cnt.')</span></a></li>'.PHP_EOL;
        ?>
        </ul>
    </div>
    <!-- } 검색된 분류 끝 -->
    <?php } ?>

리스트 나오는 부분을 if(count($where)>1){  로 둘러싸 주시면 됩니다

if(count($where)>1){ 
    
            $list_file = G5_SHOP_SKIN_PATH.'/'.$default['de_search_list_skin'];
            if (file_exists($list_file)) {
                define('G5_SHOP_CSS_URL', G5_SHOP_SKIN_URL);
                $list = new item_list($list_file, $default['de_search_list_mod'], $default['de_search_list_row'], $default['de_search_img_width'], $default['de_search_img_height']);
                $list->set_query(" select * $sql_common $sql_where {$order_by} limit $from_record, $items ");
                $list->set_is_page(true);
                $list->set_view('it_img', true);
                $list->set_view('it_id', true);
                $list->set_view('it_name', true);
                $list->set_view('it_basic', true);
                $list->set_view('it_cust_price', false);
                $list->set_view('it_price', true);
                $list->set_view('it_icon', true);
                $list->set_view('sns', true);
                echo $list->run();
            }
            else
            {
                $i = 0;
                $error = '<p class="sct_nofile">'.$list_file.' 파일을 찾을 수 없습니다.<br>관리자에게 알려주시면 감사하겠습니다.</p>';
            }
        
            if ($i==0)
            {
                echo '<div>'.$error.'</div>';
            }
        }

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