[G4] [최신게시물] 랜덤, 카테고리, 원글 아래 답글 등 > 기술자료 | 해피정닷컴

[G4] [최신게시물] 랜덤, 카테고리, 원글 아래 답글 등 > 기술자료

본문 바로가기

사이트 내 전체검색

[G4] [최신게시물] 랜덤, 카테고리, 원글 아래 답글 등 > 기술자료

그누보드 [G4] [최신게시물] 랜덤, 카테고리, 원글 아래 답글 등

페이지 정보


본문

그누보드 / extend / hp_extend_latest.php  로 파일을 만들어서 업로드합니다.


1. 최신글 랜덤으로 보이기
    랜덤 추출 함수  rand()  활용
   사용법 : <?=latest_rand("최신글스킨", "게시판이름", 게시물수, 제목글자수");?>
2. 카테고리로 최신글 보이기  # 2008-07-03 추가 , 2009-05-13 수정
   사용법 : <?=latest_category("최신글스킨", "게시판이름", 게시물수, 제목글자수, "옵션", "카테고리이름");?>
3. 답글이 원본글 밑에 붙는 방식
   사용법 : <?=latest_re("최신글스킨", "게시판이름", 게시물수, 제목글자수);?>
4. 작성일자로 최신글 추출  # 2008-07-03 추가
   사용법 : <?=latest_datetime("최신글스킨", "게시판이름", 게시물수, 제목글자수);?>


<?php
if (!defined('_GNUBOARD_')) exit;

/*
1. 최신글 랜덤으로 보이기
   랜덤 추출 함수  rand()  활용
   사용법 : <?php echo latest_rand("최신글스킨", "게시판이름", 게시물수, 제목글자수);?>
*/
// 최신글 랜덤 추출
function latest_rand($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="") {
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by rand() desc limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}

/*
2. 카테고리(분류)만 추출 최신글 보이기  ( 2009-05-13 수정 )
  사용법 : <?php echo latest_category("최신글스킨", "게시판이름", 게시물수, 제목글자수, "옵션", "카테고리이름");?>

skin/latest/스킨/latest.skin.php  을 수정합니다.
일반 최신게시물    :  {$list[$i]['href']}   를   {$list[$i]['href']}&amp;sca={$category}  로 수정
갤러리 최신게시물 :  bo_table=$bo_table  를   bo_table=$bo_table&amp;sca=$category  로 수정
*/
// 최신글 카테고리 데이타만 추출
function latest_category ($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="", $category="") {
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    $sql = " select * from $tmp_write_table where ca_name = '$category' order by wr_num limit 0, $rows ";

    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}

/*
3. 답글이 원본글 밑에 붙는 방식
   사용법 : <?php echo latest_re("최신글스킨", "게시판이름", 게시물수, 제목글자수);?>
*/
// 최신글 추출 ## 답글이 원본글 밑에 붙는 방식
function latest_re($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="") {
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_num asc, wr_id asc limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}

/*
4. 작성일자로 최신글 추출
   사용법 : <?php echo latest_datetime("최신글스킨", "게시판이름", 게시물수, 제목글자수);?>
*/
// 작성일자로 최신글 추출
function latest_datetime($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
{
    global $g4;

    if ($skin_dir)
        $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else
        $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $sql = " select * from $g4[board_table] where bo_table = '$bo_table'";
    $board = sql_fetch($sql);

    $tmp_write_table = $g4['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
    //$sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_id desc limit 0, $rows ";
    // 위의 코드 보다 속도가 빠름
    $sql = " select * from $tmp_write_table where wr_is_comment = 0 order by wr_datetime desc limit 0, $rows ";
    //explain($sql);
    $result = sql_query($sql);
    for ($i=0; $row = sql_fetch_array($result); $i++)
        $list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>



rand

(PHP 3, PHP 4 , PHP 5)
rand -- 정수형의 난수를 생성합니다.
설명
int rand ( [int min, int max])

부수적인 min, max 인수 없이 호출하면, rand()는 0과 RAND_MAX 사이의 임의의 난수를 반환합니다. 예를 들어, 5와 15(포함) 사이의 난수를 얻으려면, rand (5, 15)로 사용합니다.



참고자료
http://kr.php.net/manual/kr/function.rand.php
http://sir.co.kr/bbs/board.php?bo_table=g4_qa&wr_id=84024
http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=84600

댓글목록

등록된 댓글이 없습니다.


Total 2,643건 123 페이지
  • RSS
기술자료 목록
203
일반   14759  2007-02-03 10:50  
열람
그누보드   15607  2007-02-01 12:14 ~ 2009-05-13 00:00  
201
그누보드   18239  2007-01-28 18:45  
200
그누보드   17719  2007-01-28 06:08 ~ 2021-08-02 21:45  
199
그누보드   12829  2007-01-26 21:05  
198
ClassicASP   14471  2007-01-19 01:09 ~ 2014-09-09 00:00  
197
ClassicASP   18416  2007-01-19 00:00 ~ 2012-05-17 00:00  
196
도메인   13592  2007-01-19 01:20  
195
JavaScript   14511  2007-01-18 23:54  
194
Editor   18309  2007-01-17 11:19 ~ 2018-11-16 13:31  
193
HTML   13809  2007-01-14 22:03  
192
일반   12415  2007-01-13 00:05 ~ 2018-11-15 05:43  
191
메이크샵   12361  2007-01-09 00:38  
190
메이크샵   10752  2007-01-09 00:34  
189
메이크샵   10734  2007-01-09 00:32  
188
메이크샵   11506  2007-01-09 00:28  
187
그누보드   12304  2007-01-04 10:07  
186
그누보드   21798  2006-12-30 14:50  
185
일반   13923  2006-12-30 13:33  
184
일반   12383  2006-12-23 13:39 ~ 2019-01-14 18:23  

검색

해피정닷컴 정보

회사소개 회사연혁 협력사 오시는길 서비스 이용약관 개인정보 처리방침

회사명: 해피정닷컴   대표: 정창용   전화: 070-7600-3500   팩스: 042-670-8272
주소: (34368) 대전시 대덕구 대화로 160 대전산업용재유통단지 1동 222호
개인정보보호책임자: 정창용   사업자번호: 119-05-36414
통신판매업신고: 제2024-대전대덕-0405호 [사업자등록확인]  
Copyright 2001~2025 해피정닷컴. All Rights Reserved.