[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차 수정]
- 버전 업그레이드로 인한 랜덤이 제대로 적용 안되던것 수정
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차 수정]
- 버전 업그레이드로 인한 랜덤이 제대로 적용 안되던것 수정
|
댓글을 작성하시려면 로그인이 필요합니다.
로그인
댓글 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; } ?>
요런 식으로 하세요.
랜덤하게...
아주 좋습니다.
멋지고 감사합니다.
좋은 팁 올려 주셔서 감사합니다...^^
겔러리 자료 업그레이드 압박에서 해방!^^
할~~할~~할
너무 잘 쓰고 있습니다.
실력이 너무 부럽습니다.
설명대로 하니 잘 돌아가네요 감사합니다 ^^
잘되고있는거 2010년 6월 23일까지 확인되었습니다^ㅡ^
extend 폴더 사용해서 그런지...
원본에 이상이 없기때문에..
함수오류가 아니고선.... 제대로 될터인데..
현재까지 잘됩니다^ㅡ^
다른건 다 잘 작동하는데..
문제는 회원가입시에만 오류가 나네요.
개인정보정책동의 하고 그 다음 페이지에서 에러메시지가 뜹니다.
확인바랍니다.
다시한번 좋은 자료 주신점 감사드립니다.
1. extend 폴더가 아닌 lib 폴더에 넣었구요.
2. include_once("$g4[path]/lib/developer.lib.php"); - 최신글 나오는곳에 삽입
3. 기존 인클루드된 latest.lib.php 을 반드시 삭제해야 합니다.
휴..