이것좀 자세하게 설명해주세요 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

이것좀 자세하게 설명해주세요 정보

이것좀 자세하게 설명해주세요

본문

http://sir.co.kr/bbs/board.php?bo_table=yc4_qa&wr_id=52705#c_52713
이런 답변을 받았는데.어떻게 하라는것인지 잘 모르겠네요


lib/shop.lib.php 의

function it_name_icon($it, $it_name="", $url=1)
{
    global $g4;

    $str = "";
    if ($it_name)
        $str = $it_name;
    else
        $str = stripslashes($it[it_name]);

    if ($url)
        $str = "<a href='$g4[shop_path]/item.php?it_id=$it[it_id]'>$str</a>";

    if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
    if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
    if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
    if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
    if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
 
    // 품절
    $stock = get_it_stock_qty($it[it_id]);
    if ($stock <= 0)
        $str .= " <img src='$g4[shop_img_path]/icon_pumjul.gif' border='0' align='absmiddle' /> ";
 
    return $str;
}

위 코드에서

아이콘 출력 부분의 코드만 분리합니다.



function it_icon($it)
{
    global $g4;

    if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
    if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
    if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
    if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
    if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
 
    return $str;
}

위 코드를 적절히 수정하신후

echo $it_icon($it);

와 같은 방법으로 사용해 보시기 바랍니다.





////아이콘 관련 부분만 분리하라는게 어떤 의미인지
lib/shop.lib.php에 있는부분을 분리해서 item페이지에 넣어라는 것인지
lib/shop.lib.php에 본래있던 아이콘 관련 내용을 지우고
lib/shop.lib.php다른 부분에 넣어라는것인지
좀 자세하게 설명해주실분?

댓글 전체

shop.lib.php 파일에서
function it_name_icon($it, $it_name="", $url=1) {
~~~
}

이 함수 아래쪽에 답변에 있는 함수 추가하고
function it_icon($it) {
~~~
}


item.php 파일에서 아이콘 출력하고 싶은 부분에
<?php echo $it_icon($it); ?> 를 추가하면 됩니다.
itam.php에
<? php echo $it_icon($it); ?> 이렇게요

<? echo $it_icon($it); ?> 이렇게도 해보고..
<?php echo $it_icon($it); ?>이렇게도 해보고..


shop.lib.php 파일에서 이부분 잘라내서 아래에 넣어주고요

// 상품이름

function it_name_icon($it, $it_name="", $url=1)
{
    global $g4;

    $str = "";
    if ($it_name)
        $str = $it_name;
    else
        $str = stripslashes($it[it_name]);

    if ($url)
        $str = "<a href='$g4[shop_path]/item.php?it_id=$it[it_id]'>$str</a>";

    // 품절
    $stock = get_it_stock_qty($it[it_id]);
    if ($stock <= 0)
        $str .= " <img src='$g4[shop_img_path]/icon_pumjul.gif' border='0' align='absmiddle' /> ";
 
    return $str;
}



 // 아이콘 부분

function it_icon($it)
{
    global $g4;

    if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
    if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
    if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
    if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
    if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
 
    return $str;
}
function it_name_icon($it, $it_name="", $url=1)  부분에

if ($url)
        $str = "<a href='$g4[shop_path]/item.php?it_id=$it[it_id]'>$str</a>";

이 다음에

    if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
    if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
    if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
    if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
    if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
 
는 지우시지 마시구요


echo $it_icon($it); 가 아니라 echo it_icon($it); 로 해야겠네요~
성공했네요.
고맙습니다.^^

function it_name_icon($it, $it_name="", $url=1) 이부분에
아이콘관련 
if ($it[it_type1]) $str .= <................ 지워도 되네요

<? echo it_icon($it); ?> 이 코드가 가해결책였나봐요

 저처럼 암것도 모르거나 말귀어두운 분을위해 남깁니다.
========================================================================
shop.lib.php 원래 소스는 그대로 두고


 // 상품이름
function it_name_icon($it, $it_name="", $url=1)
{
    global $g4;

    $str = "";
    if ($it_name)
        $str = $it_name;
    else
        $str = stripslashes($it[it_name]);

    if ($url)
        $str = "<a href='$g4[shop_path]/item.php?it_id=$it[it_id]'>$str</a>";

    // 품절
    $stock = get_it_stock_qty($it[it_id]);
    if ($stock <= 0)
        $str .= " <img src='$g4[shop_img_path]/icon_pumjul.gif' border='0' align='absmiddle' /> ";
 
    return $str;
}


그 아래에 이것만 새로 넣어주고^^

// 아이콘
function it_icon($it)
{
    global $g4;

    if ($it[it_type1]) $str .= " <img src='$g4[shop_img_path]/icon_type1.gif' border='0' align='absmiddle' />";
    if ($it[it_type2]) $str .= " <img src='$g4[shop_img_path]/icon_type2.gif' border='0' align='absmiddle' />";
    if ($it[it_type3]) $str .= " <img src='$g4[shop_img_path]/icon_type3.gif' border='0' align='absmiddle' />";
    if ($it[it_type4]) $str .= " <img src='$g4[shop_img_path]/icon_type4.gif' border='0' align='absmiddle' />";
    if ($it[it_type5]) $str .= " <img src='$g4[shop_img_path]/icon_type5.gif' border='0' align='absmiddle' />";
 
    return $str;
}


itam.php 아이콘 나오길 원하는 부분에<? echo it_icon($it); ?>삽입
전체 279 |RSS
그누4 질문답변 내용 검색

회원로그인

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