최신갤러리로 홈피상단과 우측에 배너처럼 쓰는중 랜덤으로 불러오려면...
본문
1. 현재 배너용으로 쓸 게시판을 5개정도 만들었습니다.
2. 배너용으로 쓸 게시판을 홈페이지 상단이나 우측에 최신글갤러리 스킨을 이용해서 배너처럼 나오게 해서 쓰고 있습니다.
3. 그런데요 메인이나 다른페이지와 어느 게시판을 가든 최신글갤러리 형식으로 불러온 배너(이미지)라 보니 홈페이지 상단이나 우측메뉴부분에 나오게 한 이미지가 언제나 똑같잖아요?
글쓰기할때도 목록에서도...
4그래서 해당 배너용으로 쓰는 게시판에 배너용글을 몇개가 올라가있다면 갤러리최신글 매번 랜덤으로 나타나게 하고 싶습니다.
갤러리최신글 스킨을 손봐야될거 같은데요??
어느부분의 어디를 수정하면 될까요? 조언 부탁합니다~
답변 1
/lib/latest.lib.php 파일에서 최신글을 구해 옵니다.
lib.php에 추가를 하셔도 되나 그누 업데이트시 문제가 될 수 있으니
/extend/latest.lib.php를 만드시고 이름은 마음대로 하시면 됩니다.
<?php
if (!defined('_GNUBOARD_')) exit;
// 최신글 추출
// $cache_time 캐시 갱신시간
function latest_redom($skin_dir='', $bo_table, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
//static $css = array();
if (!$skin_dir) $skin_dir = 'basic';
if(G5_IS_MOBILE) {
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
} else {
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
}
$list = array();
$sql = " select * from {$g5['board_table']} where bo_table = '{$bo_table}' ";
$board = sql_fetch($sql);
$bo_subject = get_text($board['bo_subject']);
$tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
$sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by rand() limit {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i] = get_list($row, $board, $latest_skin_url, $subject_len);
}
if($cache_fwrite) {
$handle = fopen($cache_file, 'w');
$cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$bo_subject='".$bo_subject."';\n\$list=".var_export($list, true)."?>";
fwrite($handle, $cache_content);
fclose($handle);
}
/*
// 같은 스킨은 .css 를 한번만 호출한다.
if (!in_array($skin_dir, $css) && is_file($latest_skin_path.'/style.css')) {
echo '<link rel="stylesheet" href="'.$latest_skin_url.'/style.css">';
$css[] = $skin_dir;
}
*/
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
호출시에 latest("column", 'movie', 6, 25); 아닌
latest_redom("basic", $row['bo_table'], 5, 25); 호출하면 랜덤으로 가지고 올겁니다.
매번 다른 호출이니 캐쉬되는 부분은 제외 했습니다.