[G4] 최신글 - 랜덤게시물 추출 방법 - [2006.03.19 1차 수정] > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

[G4] 최신글 - 랜덤게시물 추출 방법 - [2006.03.19 1차 수정] 정보

[G4] 최신글 - 랜덤게시물 추출 방법 - [2006.03.19 1차 수정]

본문

1. extend 디렉토리에 developer.lib.php을 올립니다.

2. developer.lib.php 파일 내용은 다음과 같습니다.

=====================================  developer.lib.php  =====================================
<?
//랜덤게시물 추출 방법
function r_latest($skin_dir="", $bo_table, $rows=10, $subject_len=40)
{
    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;
}
?>
=============================================================================

3. 불러오고자 하는 곳에서 아래와 같이 불러옵니다.
<?=r_latest("최신글스킨명", 테이블명, 불러올갯수, 제목길이);?>
(적용예제) <?=r_latest("img", bbs, 5, 70);?>

[2006.03.19 1차 수정]
- 버전 업그레이드로 인한 랜덤이 제대로 적용 안되던것 수정
추천
7

댓글 44개

와우~*

'까만도둑'님께서도 정말 숨가쁘게 달려 가시네요^^;

목록보기에 관한 부분은 나름대로 관리자님의 '태클(?!)'이라 여겨집니다만...
g4가 정말로 안정궤도에 오르면 구현되지 않을까 조심스레 짐작해 봅니다^^;
한 동안 웹을 접하지 못 하여 홈피 하나 만들려고 다시 잡으니
어리둥절 한데 많은 도움이 되고있습니다..
감사합니다 까만도독님!!
오류 뜨는데요 ㅡㅡ"
Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 44

Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 46

Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 47

Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 49

Warning: Cannot modify header information - headers already sent by (output started at d:\program\apm_setup\htdocs\gnuboard4\extend\developer.lib.php:36) in d:\program\apm_setup\htdocs\gnuboard4\head.sub.php on line 50
공백을 없애세요...

마지막 부분을

 ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();
    return $content; } ?>

요런 식으로 하세요.
오류없이 잘되네요..^-^
extend 폴더 사용해서 그런지...
원본에 이상이 없기때문에..
함수오류가 아니고선.... 제대로 될터인데..
현재까지 잘됩니다^ㅡ^
좋은 자료 감사합니다.
다른건 다 잘 작동하는데..
문제는 회원가입시에만 오류가 나네요.
개인정보정책동의 하고 그 다음 페이지에서 에러메시지가 뜹니다.
확인바랍니다.
다시한번 좋은 자료 주신점 감사드립니다.
해결했습니다.
1. extend 폴더가 아닌  lib 폴더에 넣었구요.
2. include_once("$g4[path]/lib/developer.lib.php"); - 최신글 나오는곳에 삽입
3. 기존 인클루드된 latest.lib.php 을 반드시 삭제해야 합니다.

휴..
전체 3,313 |RSS
그누4 팁자료실 내용 검색

회원로그인

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