테스트 사이트 - 개발 중인 베타 버전입니다

영카트 추천상품에 이미지URL을 적용하고 싶습니다. 채택완료

스노우맨3 1년 전 조회 923

상품상세페이지는 이미지URL로 정상적으로 표시가되는데 메인화면 에서는 코드를 아래와같이 작성하였는데 이미지가 출력이 안됩니다. 이미지의 주소는 DB의 g5_shop_item테이블에 it_img1에 들었습니다. 예)https://tshop.r10s.com/point/cabinet/066/455013317.jpg

   

해당부분의 index.php파일은 아래와같이 수정해주었는데 이미지표시가 안되네요~ 고수분들의 도움 부탁드립니다.꾸벅~  

</strong></p>

<p><?php if ($default['de_type2_list_use']) { ?></p>

<p>    <!-- 추천상품 시작 { --></p>

<p>    <section class="sct_wrap"></p>

<p>        <header></p>

<p>            <h2><a href="<?php echo shop_type_url('2'); ?>">추천상품</a></h2></p>

<p>        </header></p>

<p>        <?php</p>

<p>        $list = new item_list();</p>

<p>        $list->set_type(2);</p>

<p>        $list->set_view('it_id', false);</p>

<p>        $list->set_view('it_name', true);</p>

<p>        $list->set_view('it_basic', true);</p>

<p>        $list->set_view('it_cust_price', true);</p>

<p>        $list->set_view('it_price', true);</p>

<p>        $list->set_view('it_icon', true);</p>

<p>        $list->set_view('sns', true);</p>

<p>        $list->set_view('star', true);</p>

<p> </p>

<p>        // 이미지 URL 출력 설정</p>

<p>        $list->set_view('it_img1', true); </p>

<p>        echo $list->run();</p>

<p>        ?></p>

<p>    </section></p>

<p>    <!-- } 추천상품 끝 --></p>

<p><?php } ?></p>

<p><strong>

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

답변 4개

채택된 답변
+20 포인트
R
1년 전

사용법은 class 를 참고하세요.

</p>

<p>class item_list

{

    // 상품유형 : 기본적으로 1~5 까지 사용할수 있으며 0 으로 설정하는 경우 상품유형별로 노출하지 않습니다.

    // 분류나 이벤트로 노출하는 경우 상품유형을 0 으로 설정하면 됩니다.

    protected $type;</p>

<p>    protected $list_skin;

    protected $list_mod;

    protected $list_row;

    protected $img_width;

    protected $img_height;</p>

<p>    // 상품상세보기 경로

    protected $href = "";</p>

<p>    // select 에 사용되는 필드

    protected $fields = "*";</p>

<p>    // 분류코드로만 사용하는 경우 상품유형($type)을 0 으로 설정하면 됩니다.

    protected $ca_id = "";

    protected $ca_id2 = "";

    protected $ca_id3 = "";</p>

<p>    // 노출순서

    protected $order_by = "it_order, it_id desc";</p>

<p>    // 상품의 이벤트번호를 저장합니다.

    protected $event = "";</p>

<p>    // 스킨의 기본 css 를 다른것으로 사용하고자 할 경우에 사용합니다.

    protected $css = "";</p>

<p>    // 상품의 사용여부를 따져 노출합니다. 0 인 경우 모든 상품을 노출합니다.

    protected $use = 1;</p>

<p>    // 모바일에서 노출하고자 할 경우에 true 로 설정합니다.

    protected $is_mobile = false;</p>

<p>    // 기본으로 보여지는 필드들

    protected $view_it_id    = false;       // 상품코드

    protected $view_it_img   = true;        // 상품이미지

    protected $view_it_name  = true;        // 상품명

    protected $view_it_basic = true;        // 기본설명

    protected $view_it_price = true;        // 판매가격

    protected $view_it_cust_price = false;  // 소비자가

    protected $view_it_icon = false;        // 아이콘

    protected $view_sns = false;            // SNS

    protected $view_star = false;           // 별점</p>

<p>    // 몇번째 class 호출인지를 저장합니다.

    protected $count = 0;</p>

<p>    // true 인 경우 페이지를 구한다.

    protected $is_page = false;</p>

<p>    // 페이지 표시를 위하여 총 상품수를 구합니다.

    public $total_count = 0;</p>

<p>    // sql limit 의 시작 레코드

    protected $from_record = 0;</p>

<p>    // 외부에서 쿼리문을 넘겨줄 경우에 담아두는 변수

    protected $query = "";</p>

<p>    // $type        : 상품유형 (기본으로 1~5까지 사용)

    // $list_skin   : 상품리스트를 노출할 스킨을 설정합니다. 스킨위치는 skin/shop/쇼핑몰설정스킨/type??.skin.php

    // $list_mod    : 1줄에 몇개의 상품을 노출할지를 설정합니다.

    // $list_row    : 상품을 몇줄에 노출할지를 설정합니다.

    // $img_width   : 상품이미지의 폭을 설정합니다.

    // $img_height  : 상품이미지의 높이을 설정합니다. 0 으로 설정하는 경우 썸네일 이미지의 높이는 폭에 비례하여 생성합니다.

    //function __construct($type=0, $list_skin='', $list_mod='', $list_row='', $img_width='', $img_height=0, $ca_id='') {

    function __construct($list_skin='', $list_mod='', $list_row='', $img_width='', $img_height=0) {

        $this->list_skin  = $list_skin;

        $this->list_mod   = $list_mod;

        $this->list_row   = $list_row;

        $this->img_width  = $img_width;

        $this->img_height = $img_height;

        $this->set_href(G5_SHOP_URL.'/item.php?it_id=');

        $this->count++;

    }</p>

<p>    function set_type($type) {

        $this->type = $type;

        if ($type) {

            $this->set_list_skin($this->list_skin);

            $this->set_list_mod($this->list_mod);

            $this->set_list_row($this->list_row);

            $this->set_img_size($this->img_width, $this->img_height);

        }

    }</p>

<p>    // 분류코드로 검색을 하고자 하는 경우 아래와 같이 인수를 넘겨줍니다.

    // 1단계 분류는 (분류코드, 1)

    // 2단계 분류는 (분류코드, 2)

    // 3단계 분류는 (분류코드, 3)

    function set_category($ca_id, $level=1) {

        if ($level == 2) {

            $this->ca_id2 = $ca_id;

        } else if ($level == 3) {

            $this->ca_id3 = $ca_id;

        } else {

            $this->ca_id = $ca_id;

        }

    }</p>

<p>    // 이벤트코드를 인수로 넘기게 되면 해당 이벤트에 속한 상품을 노출합니다.

    function set_event($ev_id) {

        $this->event = $ev_id;

    }</p>

<p>    // 리스트 스킨을 바꾸고자 하는 경우에 사용합니다.

    // 리스트 스킨의 위치는 skin/shop/쇼핑몰설정스킨/type??.skin.php 입니다.

    // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다.

    function set_list_skin($list_skin) {

        global $default;

        if ($this->is_mobile) {

            $this->list_skin = $list_skin ? $list_skin : G5_MSHOP_SKIN_PATH.'/'.preg_replace('/[^A-Za-z0-9 _ .-]/', '', $default['de_mobile_type'.$this->type.'_list_skin']);

        } else {

            $this->list_skin = $list_skin ? $list_skin : G5_SHOP_SKIN_PATH.'/'.preg_replace('/[^A-Za-z0-9 _ .-]/', '', $default['de_type'.$this->type.'_list_skin']);

        }

    }</p>

<p>    // 1줄에 몇개를 노출할지를 사용한다.

    // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다.

    function set_list_mod($list_mod) {

        global $default;

        if ($this->is_mobile) {

            $this->list_mod = $list_mod ? $list_mod : $default['de_mobile_type'.$this->type.'_list_mod'];

        } else {

            $this->list_mod = $list_mod ? $list_mod : $default['de_type'.$this->type.'_list_mod'];

        }

    }</p>

<p>    // 몇줄을 노출할지를 사용한다.

    // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다.

    function set_list_row($list_row) {

        global $default;

        if ($this->is_mobile) {

            $this->list_row = $list_row ? $list_row : $default['de_mobile_type'.$this->type.'_list_row'];

        } else {

            $this->list_row = $list_row ? $list_row : $default['de_type'.$this->type.'_list_row'];

        }

        if (!$this->list_row)

            $this->list_row = 1;

    }</p>

<p>    // 노출이미지(썸네일생성)의 폭, 높이를 설정합니다. 높이를 0 으로 설정하는 경우 쎰네일 비율에 따릅니다.

    // 특별히 설정하지 않는 경우 상품유형을 사용하는 경우는 쇼핑몰설정 값을 그대로 따릅니다.

    function set_img_size($img_width, $img_height=0) {

        global $default;

        if ($this->is_mobile) {

            $this->img_width = $img_width ? $img_width : $default['de_mobile_type'.$this->type.'_img_width'];

            $this->img_height = $img_height ? $img_height : $default['de_mobile_type'.$this->type.'_img_height'];

        } else {

            $this->img_width = $img_width ? $img_width : $default['de_type'.$this->type.'_img_width'];

            $this->img_height = $img_height ? $img_height : $default['de_type'.$this->type.'_img_height'];

        }

    }</p>

<p>    // 특정 필드만 select 하는 경우에는 필드명을 , 로 구분하여 "field1, field2, field3, ... fieldn" 으로 인수를 넘겨줍니다.

    function set_fields($str) {

        $this->fields = $str;

    }</p>

<p>    // 특정 필드로 정렬을 하는 경우 필드와 정렬순서를 , 로 구분하여 "field1 desc, field2 asc, ... fieldn desc " 으로 인수를 넘겨줍니다.

    function set_order_by($str) {

        $this->order_by = $str;

    }</p>

<p>    // 사용하는 상품외에 모든 상품을 노출하려면 0 을 인수로 넘겨줍니다.

    function set_use($use) {

        $this->use = $use;

    }</p>

<p>    // 모바일로 사용하려는 경우 true 를 인수로 넘겨줍니다.

    function set_mobile($mobile=true) {

        $this->is_mobile = $mobile;

    }</p>

<p>    // 스킨에서 특정 필드를 노출하거나 하지 않게 할수 있습니다.

    // 가령 소비자가는 처음에 노출되지 않도록 설정되어 있지만 노출을 하려면

    // ("it_cust_price", true) 와 같이 인수를 넘겨줍니다.

    // 이때 인수로 넘겨주는 값은 스킨에 정의된 필드만 가능하다는 것입니다.

    function set_view($field, $view=true) {

        $this->{"view_".$field} = $view;

    }</p>

<p>    // anchor 태그에 하이퍼링크를 다른 주소로 걸거나 아예 링크를 걸지 않을 수 있습니다.

    // 인수를 "" 공백으로 넘기면 링크를 걸지 않습니다.

    function set_href($href) {

        $this->href = $href;

    }</p>

<p>    // ul 태그의 css 를 교체할수 있다. "sct sct_abc" 를 인수로 넘기게 되면

    // 기존의 ul 태그에 걸린 css 는 무시되며 인수로 넘긴 css 가 사용됩니다.

    function set_css($css) {

        $this->css = $css;

    }</p>

<p>    // 페이지를 노출하기 위해 true 로 설정할때 사용합니다.

    function set_is_page($is_page) {

        $this->is_page = $is_page;

    }</p>

<p>    // select ... limit 의 시작값

    function set_from_record($from_record) {

        $this->from_record = $from_record;

    }</p>

<p>    // 외부에서 쿼리문을 넘겨줄 경우에 담아둡니다.

    function set_query($query) {

        $this->query = $query;

    }</p>

<p>    // class 에 설정된 값으로 최종 실행합니다.

    function run() {</p>

<p>        global $g5, $config, $member, $default;

        

        $list = array();</p>

<p>        if ($this->query) {</p>

<p>            $sql = $this->query;

            $result = sql_query($sql);

            $this->total_count = @sql_num_rows($result);</p>

<p>        } else {</p>

<p>            $where = array();

            if ($this->use) {

                $where[] = " it_use = '1' ";

            }</p>

<p>            if ($this->type) {

                $where[] = " it_type{$this->type} = '1' ";

            }</p>

<p>            if ($this->ca_id || $this->ca_id2 || $this->ca_id3) {

                $where_ca_id = array();

                if ($this->ca_id) {

                    $where_ca_id[] = " ca_id like '{$this->ca_id}%' ";

                }

                if ($this->ca_id2) {

                    $where_ca_id[] = " ca_id2 like '{$this->ca_id2}%' ";

                }

                if ($this->ca_id3) {

                    $where_ca_id[] = " ca_id3 like '{$this->ca_id3}%' ";

                }

                $where[] = " ( " . implode(" or ", $where_ca_id) . " ) ";

            }</p>

<p>            if ($this->order_by) {

                $sql_order = " order by {$this->order_by} ";

            }</p>

<p>            if ($this->event) {

                $sql_select = " select {$this->fields} ";

                $sql_common = " from `{$g5['g5_shop_event_item_table']}` a left join `{$g5['g5_shop_item_table']}` b on (a.it_id = b.it_id) ";

                $where[] = " a.ev_id = '{$this->event}' ";

            } else {

                $sql_select = " select {$this->fields} ";

                $sql_common = " from `{$g5['g5_shop_item_table']}` ";

            }

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

            $sql_limit = " limit " . $this->from_record . " , " . ($this->list_mod * $this->list_row);</p>

<p>            $sql = $sql_select . $sql_common . $sql_where . $sql_order . $sql_limit;

            $result = sql_query($sql);</p>

<p>            if ($this->is_page) {

                $sql2 = " select count(*) as cnt " . $sql_common . $sql_where;

                $row2 = sql_fetch($sql2);

                $this->total_count = $row2['cnt'];

            }

        }</p>

<p>        if( isset($result) && $result ){

            while ($row=sql_fetch_array($result)) {

                

                if( isset($row['it_seo_title']) && ! $row['it_seo_title'] ){

                    shop_seo_title_update($row['it_id']);

                }

                

                $row['it_basic'] = conv_content($row['it_basic'], 1);

                $list[] = $row;

            }</p>

<p>            if(function_exists('sql_data_seek')){

                sql_data_seek($result, 0);

            }

        }</p>

<p>        $file = $this->list_skin;</p>

<p>        if ($this->list_skin == "") {

            return $this->count."번 item_list() 의 스킨파일이 지정되지 않았습니다.";

        } else if (!file_exists($file)) {

            return $file." 파일을 찾을 수 없습니다.";

        } else {

            ob_start();

            $list_mod = $this->list_mod;

            include($file);

            $content = ob_get_contents();

            ob_end_clean();

            return $content;

        }

    }

}</p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

스노우맨3
1년 전
감사합니다..해결 하였습니다.

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

복스리
1년 전

$list->set_view('it_img1', true)

 

라는 옵션을 정의하였을때 다음과 같은 함수가 적용되오니 참고 바랍니다

 

</p>

<p>// 상품 이미지를 얻는다

function get_it_image($it_id, $width, $height=0, $anchor=false, $img_id='', $img_alt='', $is_crop=false)

{

    global $g5;</p>

<p>    if(!$it_id || !$width)

        return '';</p>

<p>    $row = get_shop_item($it_id, true);</p>

<p>    if(!$row['it_id'])

        return '';</p>

<p>    $filename = $thumb = $img = '';</p>

<p>    $img_width = 0;

    for($i=1;$i<=10; $i++) {

        $file = G5_DATA_PATH.'/item/'.$row['it_img'.$i];

        if(is_file($file) && $row['it_img'.$i]) {

            $size = @getimagesize($file);

            if(! isset($size[2]) || $size[2] < 1 || $size[2] > 3)

                continue;</p>

<p>            $filename = basename($file);

            $filepath = dirname($file);

            $img_width = $size[0];

            $img_height = $size[1];</p>

<p>            break;

        }

    }</p>

<p>    if($img_width && !$height) {

        $height = round(($width * $img_height) / $img_width);

    }</p>

<p>    if($filename) {

        //thumbnail($filename, $source_path, $target_path, $thumb_width, $thumb_height, $is_create, $is_crop=false, $crop_mode='center', $is_sharpen=true, $um_value='80/0.5/3')

        $thumb = thumbnail($filename, $filepath, $filepath, $width, $height, false, $is_crop, 'center', false, $um_value='80/0.5/3');

    }</p>

<p>    if($thumb) {

        $file_url = str_replace(G5_PATH, G5_URL, $filepath.'/'.$thumb);

        $img = '<img src="'.$file_url.'" width="'.$width.'" height="'.$height.'" alt="'.$img_alt.'"';

    } else {

        $img = '<img src="'.G5_SHOP_URL.'/img/no_image.gif" width="'.$width.'"';

        if($height)

            $img .= ' height="'.$height.'"';

        $img .= ' alt="'.$img_alt.'"';

    }</p>

<p>    if($img_id)

        $img .= ' id="'.$img_id.'"';

    $img .= '>';</p>

<p>    if($anchor)

        $img = $img = '<a href="'.shop_item_url($it_id).'">'.$img.'</a>';</p>

<p>    return run_replace('get_it_image_tag', $img, $thumb, $it_id, $width, $height, $anchor, $img_id, $img_alt, $is_crop);

}

 </p>

<p>

 

 

해당 함수로 이미지경로에서 이미지를 가지고 와서 보여주기때문에 추천상품인경우 예외인경우로 if문을 사용해서 적용해보시면 될꺼 같습니다.

로그인 후 평가할 수 있습니다

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

M
1년 전
$list->set_view('it_img1', true); 

->

$list->set_view('it_img', true);

이미지는 it_img이긴 합니다.

다만 이건 기본적으로 true라서 skin 단에서 처리하시는 부분을 살펴보셔야 할듯 합니다.

로그인 후 평가할 수 있습니다

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

웅푸
1년 전

사이트 주소를 줘보세요 오류내용을 확인해봐야할것같네요

일단은 it_img1 필드에 관한 코드가 있는지 확인해보시기 바랍니다.

로그인 후 평가할 수 있습니다

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

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

로그인