그누보드 5 갤러리 최신글

그누보드 5 갤러리 최신글

QA

그누보드 5 갤러리 최신글

본문

갤러리보드 최신글 불러오는 방법 중 가장 상단에 위치한 3개만 뽑아 올 수 있도록 할 수 있나요?

 

참고로 갤러리 게시판은 게시글을 올리는 순서대로 배열이 되는 것이 아닌 순서를 지정해서 중간에 끼워넣기 식이 가능하록 제작이 되어 순서가 가장 최근에 올린글도 밑으로 위치할 수 있습니다 

 

즉 3일전에 올린 글이 가장위에 위치하는 글이 될 수 있다는 말인데요 

 

가장위에 위치한 3개에 글만 지정해서 가져오도록 하고 싶어요 어떻게 해야할 까요? 도와주세요 

 

메인에 최신글 코드

 <?php echo latest('theme/pic_basic', 'gallery', 3, 23); ?>

 

 

 

 

갤러리 latest.skin.php 코드

<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
include_once(G5_LIB_PATH.'/thumbnail.lib.php');

// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">', 0);
$thumb_width = 375;
$thumb_height = 240;
?>

<div class="pic_lt">
    <ul class="row">
    <?php
    for ($i=0; $i<count($list); $i++) {
    $thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id'], $thumb_width, $thumb_height, false, true);

    if($thumb['src']) {
        $img = $thumb['src'];
    } else {
        $img = G5_THEME_IMG_URL.'/no_image.png';
        $thumb['alt'] = '이미지가 없습니다.';
    }
    $img_content = '<img src="'.$img.'" alt="'.$thumb['alt'].'" >';
    ?>
        <li class="gall_thum">           
            <a href="<?php echo $list[$i]['href'] ?>" class="lt_img"><?php echo $img_content; ?></a>
            <div class="max-lines">
                <span class="bg_blue">Photo Gallery</span>
            <?php
            if ($list[$i]['icon_secret']) echo "<i class=\"fa fa-lock\" aria-hidden=\"true\"></i><span class=\"sound_only\">비밀글</span> ";

           // if ($list[$i]['icon_new']) echo "<span class=\"new_icon\">N<span class=\"sound_only\">새글</span></span>";

            if ($list[$i]['icon_hot']) echo "<span class=\"hot_icon\">H<span class=\"sound_only\">인기글</span></span>";

 
            echo "<a href=\"".$list[$i]['href']."\"> ";
            if ($list[$i]['is_notice'])
                echo "<strong>".$list[$i]['subject']."</strong>";
            else
                echo $list[$i]['subject'];

            // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }

             //echo $list[$i]['icon_reply']." ";
           // if ($list[$i]['icon_file']) echo " <i class=\"fa fa-download\" aria-hidden=\"true\"></i>" ;
            //if ($list[$i]['icon_link']) echo " <i class=\"fa fa-link\" aria-hidden=\"true\"></i>" ;

            if ($list[$i]['comment_cnt'])  echo "
            <span class=\"lt_cmt\">+ ".$list[$i]['wr_comment']."</span>";
            echo "</div>";
            echo "</a>";
            ?>
            <!--<span class="lt_date"><i class="fa fa-clock"></i> <?php echo $list[$i]['datetime'] ?></span>-->
        </li>
    <?php }  ?>
    <?php if (count($list) == 0) { //게시물이 없을 때  ?>
    <li class="empty_li">게시물이 없습니다.</li>
    <?php }  ?>
    </ul>
    <div class="lt_more">
        <a href="<?php echo G5_BBS_URL ?>/board.php?bo_table=<?php echo $bo_table ?>" class="btn2">
           <span>더보기</span>
           <div></div>
       </a>
   </div>
</div>
 

 

이 질문에 댓글 쓰기 :

답변 2

폰이라 자세히 작성드리진 못하는데 lib/latest.lib.php에서 쿼리문에 조건문으로 order by를 붙여주시면 될거같습니다

 

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

 

컴터로 돌아왔습니다..

lib/latest.lib.php에서 

$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";

이부분을 쪼개서 조건문을 달아야하는데요 예를들어서.. 내가 사용하는 게시판 명을 기준으로 작성하고 싶으시다면,

$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 ";

if ($bo_table == "gallery") {

$sql .= " order by wr_datetime desc limit 0, {$rows} "; // 갤러리게시판 최근글을 불러올때 날짜 최근순

} else {

$sql .= " order by wr_num limit 0, {$rows} "; // 갤러리게시판이 아닐때 원본

}

 

$bo_table == "gallery" 이부분을 조건을 작성해서 바까주시면 

latest 함수로 불러올때 gallery를 불러오면 최종 sql문은 

select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_datetime desc limit 0, {$rows}

이렇게 되실겁니다

아르키어드님 답변 감사합니다 아르키어드님께서 말씀해주신대로 수정을 하였는데 적용이 되지 않아서 결국 리스트 정렬 필드를 수정하여 적용했습니다 그래도 답변 내용을 보니 정말 도움이 많이 되었습니다 이런식으로 변경도 가능하구나 하고요 감사합니다

https://sir.kr/qa/?unanswered=&sst=wr_num&s_tag=%EA%B7%B8%EB%88%84%EB%B3%B4%EB%93%9C5&stx=%EA%B0%A4%EB%9F%AC%EB%A6%AC+%EC%B5%9C%EC%8B%A0%EA%B8%80

 

검색해보니 많이 나와요

참고하시길...^^

답변을 작성하시기 전에 로그인 해주세요.
전체 28
QA 내용 검색

회원로그인

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