쇼핑몰에서 사용할 오늘 본 상품 관련 코드
<?php
if (!defined(“_GNUBOARD_”)) exit; // 개별 페이지 접근 불가
$product_length = 3;
$tv_idx = get_session(“ss_tv_idx”);
?>
<?php if($tv_idx) { ?>
<div id=”TodayView”>
<div class=”tv_title”></div>
<div class=”tv_product”>
<div>
<ul>
<?php
for ($i=1; $i<=$tv_idx; $i++) {
$tv_it_id = get_session(“ss_tv[$i]”);
$rowx = sql_fetch(” select it_id, it_name, ca_id from $g4[shop_item_table] where it_id = ‘$tv_it_id’ “);
$it_name = get_text(addslashes($rowx[‘it_name’]));
$href = “$g4[shop_path]/item.php?ca_id=$rowx[ca_id]&it_id=$rowx[it_id]”;
$file = “{$rowx[it_id]}_lt”;
//get_item_image(파일명, 가로크기, 세로크기, noimage파일, alt)
$img = get_list_image($file, 73, 58, “$g4[img_path]/noimage.jpg”, $it_name);
$tv_product = “<a href=”$href”>” . $img . “</a>”;
?>
<li><?php echo $tv_product; ?></li>
<?php
}
?>
</ul>
</div>
</div><!– /tv_product –>
<div class=”tv_navi”><img src=”<?php echo $g4[shop_img_path]; ?>/todayview_btn_up.png” id=”todayviewUp” class=”pointer” /><img src=”<?php echo $g4[shop_img_path]; ?>/todayview_btn_down.png” id=”todayviewDown” class=”pointer” /></div>
</div><!– /TodayView –>
<?php } ?>
<div id=”DlPrice”><img src=”<?php echo $g4[shop_img_path]; ?>/todayview_delivery.png” class=”send_cost_info pointer” alt=”지역별 배송비확인” /></div>
<script type=”text/javascript”>
var product_length = parseInt(“<?php echo $product_length; ?>”);
var tv_idx = parseInt(“<?php echo $tv_idx; ?>”);
var up_click_count = down_click_count = 0;
$(function() {
if(tv_idx > product_length) {
$(‘div.tv_product’).height(210);
$(‘#todayviewUp’).addClass(“pointer”);
up_click_count = Math.ceil(tv_idx / product_length) – 1;
}
$(‘#todayviewUp’).click(function() {
if(up_click_count) {
var div_position = parseInt($(‘div.tv_product div’).css(“top”));
$(‘div.tv_product div’).stop().animate(
{ “top”: div_position – 210 }, 500,
function() {
up_click_count–;
down_click_count++;
}
);
} else {
alert(“오늘 본 상품 마지막입니다.”);
}
});
$(‘#todayviewDown’).click(function() {
if(down_click_count) {
var div_position = parseInt($(‘div.tv_product div’).css(“top”));
$(‘div.tv_product div’).stop().animate(
{ “top”: div_position + 210 }, 500,
function() {
up_click_count++;
down_click_count–;
}
);
} else {
alert(“오늘 본 상품 처음입니다.”);
}
});
});
</script>
대충 짜보긴 했는데.. 이거 제대로 한 건지 모르겠다. 머리가 멍해져서 대충 테스트 하니 맞는 것 같은데.. 에혀!~