무한스크롤 기능 구현 > 그누보드5 팁자료실

그누보드5 팁자료실

무한스크롤 기능 구현 정보

무한스크롤 기능 구현

본문

1. list.php : 스킨/list.skin.php 에 맨 하단에 추가

    $(".pageListArea .tbl_head01").append(data); <- 추가될 위치 지정



2. read.page.php : 스킨/read.page.php 파일 추가

    여기서는 추가될 형식에 맞춰서 html 수정을 보셔야 합니다.


[주의사항] wr_id 값이 작은 것들을 가져오고 있습니다.

정렬 순서는 잘 맞추서 수정하세요.



list.php

================================
$last_wr_id :
for 문에서 $last_wr_id = $list[$i]["wr_id"]; <-- 이 부분을 넣어주셔야 합니다.


<script>

    var page = 2;
    var last_wr_id = <?php echo $last_wr_id; ?>;

    $(window).scroll(function () {

        if ($(window).scrollTop() == $(document).height() - $(window).height()) {

            $.post("<?php echo $board_skin_url;?>/read.page.php", {bo_table:"<?=$bo_table;?>", page:page, last_wr_id:last_wr_id}, function (data) {
                //$(".pageListArea .tbl_head01").append("<div style='height:500px;'>추가된 페이지</div>");
                $(".pageListArea .tbl_head01").append(data);

                page++;
            });

        }
    });
</script>

=============================================

 

 

read.page.php

=============================================

<?php

include_once('../../../../../../common.php');

$bo_table = $_POST["bo_table"];
$page = $_POST["page"];
$last_wr_id = $_POST["last_wr_id"];
if (!$bo_table || !$page) exit;


$readTable = "g5_jejubbs_write_" . $bo_table;

$sql = " select * from {$readTable} where wr_id < " . $last_wr_id . " order by " . $board["bo_sort_field"] . " limit 0, 20 ";
$result = sql_query($sql);

while ($row = sql_fetch_array($result)) {
    $last_wr_id = $row["wr_id"];
    //print_r($row);
?>
<div class="list">

    <div class="subj"><a href="<?=G5_BBS_URL;?>/board.php?bo_table=<?=$bo_table;?>&wr_id=<?=$row["wr_id"];?>">
        <?php echo cut_str($row["wr_subject"], 20, ".."); ?>
    </a></div>

    <div class="info">
        <div style="float:right">조회수: <?php echo $row['wr_hit'] ?></div>
        <?php echo $row['wr_name']; ?>&nbsp;( <?php echo cut_str($row['wr_datetime'], 10, ""); ?> )
    </div>

</div>
<?php } ?>
<script>
    last_wr_id = <?php echo $last_wr_id; ?>;
</script>

=============================================
추천
10

댓글 10개

내용중에서
$readTable = "g5_jejubbs_write_" . $bo_table;
는 아래와 같이 변경하는것이 어떨까요?
$readTable = $g5['write_prefix'] . $bo_table;
이거 알기 쉽게 정리해주시면 안될까요?
1. list.php : 스킨/list.skin.php 에 맨 하단에 추가  list.php라고 하고 내용은 list.skin.php라고 하니 무슨 말인지 모르겟습니다.
전체 2,411 |RSS
그누보드5 팁자료실 내용 검색

회원로그인

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