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

특정게시판 최신글내용을 인덱스로

· 3년 전 · 3237 · 6

특정 게시판목록을 인덱스로 설정하는 방법은 있으나

특정게시판의 마지막글(최신글)을 인덱스로 설정하는 방법이 없어

질문만하다가 겨우 방법을 찾아 혹시 필요한 분이 있을가 해서 올려둡니다.

 

참고

1. 마지막에 등록된 글의 wr_id 값 구하기

https://gnustudy.com/bbs/board.php?bo_table=skin_board&wr_id=211

 

2. 인덱스(index) 페이지에 특정 게시판을 직접 출력하기

https://gnustudy.com/bbs/board.php?bo_table=gnu_tip&wr_id=110

 

3. 내용불러오기 (댓글)

https://amina.co.kr/bbs/board.php?bo_table=apms_qa&wr_id=93109&sfl=wr_subject&stx=%EC%9D%B8%EB%8D%B1%EC%8A%A4+%EB%82%B4%EC%9A%A9&sop=and

------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------

extend/user.config.php 파일에 함수 추가

 

function get_latest_wrid($bo_table, $ca_name='')
{
    global $g5;

    if ($ca_name)
        $sql_where = " and ca_name = '$ca_name' ";

    $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    $row = sql_fetch(" select wr_id from {$tmp_write_table} where wr_is_comment = 0 {$sql_where} order by wr_id desc limit 1 ");
    return $row['wr_id'];
}

 

------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------

index.php 수정

 

<?php
include_once('./_common.php');
define('_INDEX_', true);
require_once(G5_BBS_PATH.'/board.php');
return;
?>

------------------------------------------------------------------------------------------

bbs/board.php 수정 (빨간 부분이 참고2 에서 추가된 부분입니다.)

 

파일 상단 include_once('./_common.php'); 바로 아랫 부분에 다음 내용 추가

 

if(defined('_INDEX_')) {
    $bo_table = 'notice'; // 인덱스용 게시판id
    $write_table = $g5['write_prefix'] . $bo_table;
    $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
    $latest_wrid = get_latest_wrid('notice');
    $wr_id = $latest_wrid;
    $write = sql_fetch(" select * from $write_table where wr_id = '$wr_id' ");


    if (!$board['bo_table']) {
        alert_close('인덱스용 게시판이 생성되지 않았습니다.');
    }

    if (G5_IS_MOBILE) {
        $board_skin_path    = get_skin_path('board', $board['bo_mobile_skin']);
        $board_skin_url    = get_skin_url('board', $board['bo_mobile_skin']);
    } else {
        $board_skin_path    = get_skin_path('board', $board['bo_skin']);
        $board_skin_url    = get_skin_url('board', $board['bo_skin']);
    }
}

------------------------------------------------------------------------

위 내용 중 여기에서 메인 페이지로 사용하고 싶은 게시판 id 입력

$bo_table = 'notice'; // 인덱스용 게시판id

$latest_wrid = get_latest_wrid('notice');

 

-----------------------

-----------------------

-----------------------

기타

특정 게시판의 특정 게시물을 인덱스로 설정하고싶다면

extend/user.config.php (변경필요없음)

index.php -> 위와 동일

--------------

board.php 아래와 같이 수정

 

if(defined('_INDEX_')) {
    $bo_table = 'notice'; // 인덱스용 게시판id
    $write_table = $g5['write_prefix'] . $bo_table;
    $board = sql_fetch(" select * from {$g5['board_table']} where bo_table = '$bo_table' ");
    $wr_id = '게시물번호';
    $write = sql_fetch(" select * from $write_table where wr_id = '$wr_id' ");


    if (!$board['bo_table']) {
        alert_close('인덱스용 게시판이 생성되지 않았습니다.');
    }

    if (G5_IS_MOBILE) {
        $board_skin_path    = get_skin_path('board', $board['bo_mobile_skin']);
        $board_skin_url    = get_skin_url('board', $board['bo_mobile_skin']);
    } else {
        $board_skin_path    = get_skin_path('board', $board['bo_skin']);
        $board_skin_url    = get_skin_url('board', $board['bo_skin']);
    }
}

댓글 작성

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

로그인하기

댓글 6개

감사합니다.
감사합니다 :)
3년 전
감사합니다.
감사합니다
3년 전
감사 합니다.
감사합니다

게시글 목록

번호 제목
24318
24317
24315
24309
24294
24293
24277
24262
24260
24253
24251
24236
24233
24228
24226
24221
24214
24203
24201
24199
24196
24195
24194
24192
24191
24187
24185
24183
24172
24168