테스트 사이트 - 개발 중인 베타 버전입니다

최신글 게시판 선택하기 채택완료

불량닭발 2년 전 조회 2,531

메인에서 최신글을 보여줄때 3개 게시판을 합쳐서 최신글을 보여주고자 합니다.

그누보드 버전은 5.4입니다.

 

아래 두개 링크를 참고해서 all 및 group 둘다 해봤는데 반응이 없네요.

두개 다 게시물이 없습니다. 로 표시가 뜨네요.

https://sir.kr/g5_tip/4103

http://www.gnuwiz.com/bbs/board.php?bo_table=latest_tip&wr_id=5

 

 

현재 lib/latest.lib는 카테고리 별 분류만 추가해둔 상태입니다.

</p>

<p><?php

if (!defined('_GNUBOARD_')) exit;

@include_once(G5_LIB_PATH.'/thumbnail.lib.php');</p>

<p>// 최신글 추출

// $cache_time 캐시 갱신시간

function latest($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='')

{

    global $g5;

    

    // 카테고리 별 분류

    list($bo_table, $category) = explode("|", $bo_table);

    if($category) $where = " AND ca_name = '".$category."' ";

    </p>

<p>    if (!$skin_dir) $skin_dir = 'basic';

    

    $time_unit = 3600;  // 1시간으로 고정</p>

<p>    if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {

        if (G5_IS_MOBILE) {

            $latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            if(!is_dir($latest_skin_path))

                $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);

        } else {

            $latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];

            $latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);

        }

        $skin_dir = $match[1];

    } else {

        if(G5_IS_MOBILE) {

            $latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;

            $latest_skin_url  = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;

        } else {

            $latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;

            $latest_skin_url  = G5_SKIN_URL.'/latest/'.$skin_dir;

        }

    }</p>

<p>    $caches = false;</p>

<p>    if(G5_USE_CACHE) {

        $cache_file_name = "latest-{$bo_table}-{$skin_dir}-{$rows}-{$subject_len}-".g5_cache_secret_key();

        $caches = g5_get_cache($cache_file_name, (int) $time_unit * (int) $cache_time);

        $cache_list = isset($caches['list']) ? $caches['list'] : array();

        g5_latest_cache_data($bo_table, $cache_list);

    }</p>

<p>    if( $caches === false ){</p>

<p>        $list = array();</p>

<p>        $board = get_board_db($bo_table, true);</p>

<p>        if( ! $board ){

            return '';

        }</p>

<p>        $bo_subject = get_text($board['bo_subject']);</p>

<p>        $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름

        // 2022-11-17    카테고리 별 분류

        //$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".$where." order by wr_datetime desc limit 0, {$rows} ";

        

        $result = sql_query($sql);

        for ($i=0; $row = sql_fetch_array($result); $i++) {

            try {

                unset($row['wr_password']);     //패스워드 저장 안함( 아예 삭제 )

            } catch (Exception $e) {

            }

            $row['wr_email'] = '';              //이메일 저장 안함

            if (strstr($row['wr_option'], 'secret')){           // 비밀글일 경우 내용, 링크, 파일 저장 안함

                $row['wr_content'] = $row['wr_link1'] = $row['wr_link2'] = '';

                $row['file'] = array('count'=>0);

            }

            $list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);</p>

<p>            $list[$i]['first_file_thumb'] = (isset($row['wr_file']) && $row['wr_file']) ? get_board_file_db($bo_table, $row['wr_id'], 'bf_file, bf_content', "and bf_type between '1' and '3'", true) : array('bf_file'=>'', 'bf_content'=>'');

            $list[$i]['bo_table'] = $bo_table;

            // 썸네일 추가

            if($options && is_string($options)) {

                $options_arr = explode(',', $options);

                $thumb_width = $options_arr[0];

                $thumb_height = $options_arr[1];

                $thumb = get_list_thumbnail($bo_table, $row['wr_id'], $thumb_width, $thumb_height, false, true);

                // 이미지 썸네일

                if($thumb['src']) {

                    $img_content = '<img src="'.$thumb['src'].'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'">';

                    $list[$i]['img_thumbnail'] = '<a href="'.$list[$i]['href'].'" class="lt_img">'.$img_content.'</a>';

                // } else {

                //     $img_content = '<img src="'. G5_IMG_URL.'/no_img.png'.'" alt="'.$thumb['alt'].'" width="'.$thumb_width.'" height="'.$thumb_height.'" class="no_img">';

                }

            }</p>

<p>            if(! isset($list[$i]['icon_file'])) $list[$i]['icon_file'] = '';

        }

        g5_latest_cache_data($bo_table, $list);</p>

<p>        if(G5_USE_CACHE) {</p>

<p>            $caches = array(

                'list' => $list,

                'bo_subject' => sql_escape_string($bo_subject),

            );</p>

<p>            g5_set_cache($cache_file_name, $caches, (int) $time_unit * (int) $cache_time);

        }

    } else {

        $list = $cache_list;

        $bo_subject = (is_array($caches) && isset($caches['bo_subject'])) ? $caches['bo_subject'] : '';

    }</p>

<p>    ob_start();

    include $latest_skin_path.'/latest.skin.php';

    $content = ob_get_contents();

    ob_end_clean();</p>

<p>    return $content;

}

?></p>

<p>

 

아래는 latest 스킨 코드입니다.

</p>

<p><?php for ($i=0; $i<count($list); $i++) {  ?>

    <div class="card">

        <a href="<?=$list[$i]['href']?>">

            <span class="card_image">

                <?php

                    $thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'], $imgwidth, $imgheight, false, true);

                    $img_content = '<img src="/imgs/noImage.jpg" alt="no image" >';

                    if($thumb['src']) {

                        $img_content = '<img src="'.$thumb['src'].'" alt="'.$list[$i]['subject'].'">';

                    }

                    echo $img_content;        

                ?>

                <b><?php echo $list[$i]['subject']; ?></b>

            </span>

        </a>

    </div>

<?php }  ?></p>

<p><?php if (count($list) == 0) { //게시물이 없을 때  ?>

<div style="width: 100%; text-align:center;">게시물이 없습니다.</div>

<?php }  ?></p>

<p>

 

도움 부탁 드립니다.

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
플라이
2년 전

리스트 나오는 쿼리 부분을 찍어서 체크를 해보셔야 할듯 한데요

지금 latest에는 하나의 게시판만 불러오게 처리되어 있는걸로 확인됩니다.

 

참고 주소처럼

oard_new 테이블의 게시판 id 값을 기준으로 해서 게시판 데이터를 for문으로 해서 불러와야 하는 부분이니 참고 사이트 소스를 적용하시면 될듯 합니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

불량닭발
2년 전
혹시 버전 문제로 참고 URL 방법이 안먹히거나 제가 원 소스를 잘못 수정해서 안되나 싶어서요.
제가 직접 코드를 짤 능력은 안되서 같은 증상이나 해결하신 노하우가 있으신가 싶어서요.
플라이
2년 전
함수를 추가 적용해 보시고 호출하셔서 사용해 보세요
저 기능이 안되는거 같진 않은데 잘못 적용하시면 오류는 날수 있습니다.
작업전에 백업을 필히 해서 적용해 주시고 그래도 안되시면 제작의뢰로 요청하시는게 효과적이실듯 합니다.
불량닭발
2년 전
개발자가 바빠서 간단하게 처리해볼려고 했는데 잘 안되네요...
걍 개발자한테 맡겨야 겠네요... 답변 감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

링크 남기신 2개의 방법은 board_new_table 에서 가져 옵니다.
혹 가져오는 게시판에 글이 오래 된거 아닌가요?
새글 써서 함 해보세요.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

최신글을 보여줄때 3개 게시판을 합쳐서 최신글을 보여주고자 합니다.

===

어떤 식으로 순서를 정하셨나요?

로그인 후 평가할 수 있습니다

답변에 대한 댓글 2개

불량닭발
2년 전
출력되는 순서는 등록일 순서 입니다.
엑스엠엘
2년 전
select * from (
( select * from g5_write_free where wr_is_comment = 0 order by wr_datetime desc limit 0, 10 )
union
( select * from g5_write_notice where wr_is_comment = 0 order by wr_datetime desc limit 0, 10 )
union
( select * from g5_write_qa where wr_is_comment = 0 order by wr_datetime desc limit 0, 10 ) ) A order by wr_datetime limit 10
이런 식으로 query를 만들어 보세요.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인