최신글 정렬 질문입니다.
본문
최신순
히트순
코멘트순
랜덤
이렇게 나오게 하고 싶은데 그누4에서는 어떤분께서 도움주셔서 아래의 소스처럼 쓰고 있었습니다.
그누5에서는 방법이 없을까요?
// latest_random 랜덤으로 정렬
function latest_random($skin_dir="", $bo_tables, $rows=10, $subject_len="", $brch="", $la_num="", $options="", $f_rows="")
{
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();
$rows2 = $rows* 2; // 비밀글을 제외할 때 rows가 부족할까봐 여유있게
array_walk( $bo_tables , 'quoting');
$bo_tables= implode( ',', $bo_tables);
$sql = " select DISTINCT wr_id, bo_table from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by wr_hit desc limit $f_rows, $rows2 ";
$result = sql_query($sql);
$j = 0;
$k = 0;
while ($row = sql_fetch_array($result)) {
if ($j >= $rows) break; // rows에 지정된거보다 많으면 loop를 중단. 비밀글이 많으면 rows보다 적은 열이 return됨 (그대로 오꼭?중요하죠)
// 게시판 테이블
$sql3 = " select * from $g4[board_table] where bo_table = '$row[bo_table]'";
$board = sql_fetch($sql3);
$tmp_write_table = $g4[write_prefix] . $row[bo_table];
$sql2 = " select * from $tmp_write_table where wr_id = '$row[wr_id]' ";
$row2 = sql_fetch($sql2);
if (!strstr($row2[wr_option], "secret")) {
$list[$j] = get_list($row2, $board, $latest_skin_path, $subject_len);
$list[$j][bo_name] = $board[bo_subject];
$list[$j][bo_tb] = $row[bo_table];
$j++;
}
}
$result4 = sql_fetch(" select gr_subject from $g4[group_table] where gr_id = '$gr_id' ");
$skin_title = "$result4[gr_subject]";
$skin_title_link = "?url=$g4[bbs_path]/new.php?gr_id=$gr_id";
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
답변을 작성하시기 전에 로그인 해주세요.