보

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

· 2013-10-28 (월) 13:31:19 · 1241 · 6
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다른 부분에 넣어라는것인지
좀 자세하게 설명해주실분?
|

댓글 6개

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

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


item.php 파일에서 아이콘 출력하고 싶은 부분에
<?php echo $it_icon($it); ?> 를 추가하면 됩니다.
2013-10-29 (화) 15:11:51
<?php echo $it_icon($it); ?> 추가했더니.헤드 아랫부분이 안나와요 ㅎㅎ
어떻게 추가하셨나요?
2013-10-29 (화) 18:03:14
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); 로 해야겠네요~
2013-10-29 (화) 19:18:05
성공했네요.
고맙습니다.^^

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); ?>삽입
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

66,531건

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

+
제목 글쓴이 날짜 조회
13-10-28 조회 1,656
13-10-28 조회 1,725
13-10-28 조회 1,340
13-10-28 조회 1,041
13-10-28 조회 1,831
13-10-28 조회 1,122
13-10-28 조회 1,762
13-10-28 조회 1,242
13-10-28 조회 1,814
13-10-28 조회 1,195
13-10-28 조회 861
13-10-28 조회 974
13-10-28 조회 2,201
13-10-28 조회 1,430
13-10-28 조회 1,318
13-10-28 조회 3,562
13-10-28 조회 1,082
13-10-27 조회 1,787
13-10-27 조회 1,124
13-10-27 조회 1,129