[최신글]원하는 게시판만 선택해서하기
latest.lib.php 하단에 아래 함수를 추가하시면됩니다.
[code]
<?php
// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)
function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
if (!$skin_dir) $skin_dir = 'basic';
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
if (G5_IS_MOBILE) {
$latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
if(!is_dir($latest_skin_path))
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
} else {
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
}
$skin_dir = $match[1];
} else {
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_common = " from {$g5['board_new_table']} a where find_in_set(a.bo_table, '{$bo_tables}')";
$sql_common .= " and a.wr_id = a.wr_parent ";
$sql_order = " order by a.bn_id desc ";
$sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";
$board = sql_fetch($sql);
$tmp_write_table = $g5['write_prefix'] . $row['bo_table'];
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");
$list[$i] = $row2;
$list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);
$list[$i]['bo_subject'] = $row['bo_subject'];
$list[$i]['bo_table'] = $row['bo_table'];
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
[/code]
사용방법
[code]
echo latest_all("스킨명", "게시판명1,게시판명2,게시판명3,게시판명4", 출력갯수, 글자수);
[/code]
사용방법 예시
[code]
echo latest_all("basic", "notice,qna,news,faq", 10, 20);
[/code]
2016/10/20 추가 코드
이미지 썸네일 사용 갤러리 스킨을 사용할경우
해당 skin/latest/스킨명/latest.skin.php 파일을 열어서 보시면
대부분은 아래와 같은 코드로 되어있습니다.
[code]
$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id']
[/code]
이부분을 아래와 같이 바꿔주시면 적용가능합니다.
[code]
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'],
[/code]
[code]
<?php
// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)
function latest_all($skin_dir='', $bo_tables, $rows=10, $subject_len=40, $cache_time=1, $options='')
{
global $g5;
if (!$skin_dir) $skin_dir = 'basic';
if(preg_match('#^theme/(.+)$#', $skin_dir, $match)) {
if (G5_IS_MOBILE) {
$latest_skin_path = G5_THEME_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
if(!is_dir($latest_skin_path))
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
} else {
$latest_skin_path = G5_THEME_PATH.'/'.G5_SKIN_DIR.'/latest/'.$match[1];
$latest_skin_url = str_replace(G5_PATH, G5_URL, $latest_skin_path);
}
$skin_dir = $match[1];
} else {
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_common = " from {$g5['board_new_table']} a where find_in_set(a.bo_table, '{$bo_tables}')";
$sql_common .= " and a.wr_id = a.wr_parent ";
$sql_order = " order by a.bn_id desc ";
$sql = " select a.* {$sql_common} {$sql_order} limit 0, {$rows}";
$result = sql_query($sql);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$sql = " select * from {$g5['board_table']} where bo_table = '{$row['bo_table']}' ";
$board = sql_fetch($sql);
$tmp_write_table = $g5['write_prefix'] . $row['bo_table'];
$row2 = sql_fetch(" select * from {$tmp_write_table} where wr_id = '{$row['wr_id']}' ");
$list[$i] = $row2;
$list[$i] = get_list($row2, $board, $latest_skin_url, $subject_len);
$list[$i]['bo_subject'] = $row['bo_subject'];
$list[$i]['bo_table'] = $row['bo_table'];
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>
[/code]
사용방법
[code]
echo latest_all("스킨명", "게시판명1,게시판명2,게시판명3,게시판명4", 출력갯수, 글자수);
[/code]
사용방법 예시
[code]
echo latest_all("basic", "notice,qna,news,faq", 10, 20);
[/code]
2016/10/20 추가 코드
이미지 썸네일 사용 갤러리 스킨을 사용할경우
해당 skin/latest/스킨명/latest.skin.php 파일을 열어서 보시면
대부분은 아래와 같은 코드로 되어있습니다.
[code]
$thumb = get_list_thumbnail($bo_table, $list[$i]['wr_id']
[/code]
이부분을 아래와 같이 바꿔주시면 적용가능합니다.
[code]
$thumb = get_list_thumbnail($list[$i]['bo_table'], $list[$i]['wr_id'],
[/code]
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기
댓글 49개
예를들어 최신글을 2군대에 뿌려주려고 한다면
공지사항을 2군대에 뿌려주려고 하는데
공지사항이 특정그룹에 속하게된다면 한군대에서만 뿌릴수가있죠
그룹설정을 하지않더라도 뿌려줄수있다는게 장점이지요
저는 위에 있는 긴 소스를 latest.lib.php [?>바로 밑에 몽땅 다 넣어봤습니다
그렇게 하는게 맞는지 모르겠습니다
고맙습니다 (--)(__)
이거...썸네일은 가져오지 못하네요 ㅠㅠ
[http://blog-imgs-44.fc2.com/w/a/r/wareureu/227.gif]
이거는 있는데
latest.lib.php 는 파일이 없는데
sking/latest/스킨명/lib 여기 안에 있는 php에 넣으라는 건가요??
echo latest_all("simple_gallery", "active_support01,self_support02", 3, 15);
이렇게 했는데, 한개의 게시판 내용만 나옵니다.
감사하게 사용하겠습니다.
글제목앞에 그게시판 명을 넣고싶습니다ㅜㅜ
아이콘으로 넣고싶은데 어떻게 해야될까요 ㅠㅠ
아니면 게시판 이름이라도 뜨게 하고싶네요..
스타일에서 그냥 숨겨야 할까봐요;
[http://sir.kr/data/editor/1807/ba1225ae13165d5bed0a210fad509933_1532586333_4356.png]
echo latest_all("basic", "gaia01,gaia0202", 3, 15);
위와같은 형식으로 넣었는데 왜 안되죠?
그니까 위에 본문 길다란거를 latest.lib.php 파일 맨 하단에 추가하고나서
또 그 아래에 echo latest_all("basic", "gaia01,gaia0202", 3, 15); 을 넣었습니다.
하나의 게시판 gaia01 만 출력됩니다.ㅠㅠ
앞전에 ('notice', 'gallery', 'bbs1', 'bbs2') 추가하였는데 최신글과 최신갤러리 하나도 되질안아요
기본 갤러리 하나만 나옵니다 어떻게되는지요 그림참조
[http://sir.kr/data/editor/1812/24e0c72c044186f0f30d858ac091287b_1546063799_6045.jpg]
$list[$i]['bo_subject'] = $row['bo_subject']; 요줄을
$list[$i]['bo_subject'] = $board['bo_subject']; 요렇게 바꾸니 되네요. ^^
신고가 접수되어 자동으로 블라인드 된 댓글입니다. 원문을 보시려면 를 클릭하세요.
찾고있었던 기능이네요~~
감사합니다!
좋은소스 감사합니다.
두개의 게시판을 최신글로 불러오는건 성공했는데 링크 연결이 제대로 되지 않는거 같은데 이 부분은 어떻게 수정할 수 있을까요~?
게시물 링크 안 걸릴 때는
<a href="<?php echo get_pretty_url($list[$i]['bo_table'], $list[$i]['wr_id']); ?>">
이렇게 바꿔주기!