채택완료

여러게시판의 최신글 받아오는데 질문있습니다.

2017-07-21 (금) 11:02:00 2,746

https://sir.kr/g5_tip/4103 < 그누위즈님 글

참고하여 만들었는데 작동이 되질 않습니다.

// $bo_tables 테이블들 사이 콤마(,) 단위로 구분해서 넣을 것, 콤마 사이에 공백 없이 (ex aaa,bbb,)

latest.lib.php

Copy
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;}

index.php

Copy
echo latest_all("basic",'notice,Testimony',5,20);

|

답변 2개 / 댓글 2개

채택된 답변
+20 포인트
2017-07-21 (금) 16:01:49

작동 잘하는 거 아닌가요?

혹시 모르니 pma로 g5_board_new 테이블에 가셔서 notice, Testimony 테이블의 데이터가 있는지 확인해 보세요.

답변에 대한 댓글 2개

g5_board_new 에 데이터가 없는데 어떻게 해야하나요? 왕초보입니다.
관리자 페이지 - 환경설정 - 기본환경설정 - 최근게시물 삭제 여기 날짜를 넉넉하게 주세요.
그러면 설정한 날짜만큼 g5_board_new 테이블에서 살아(?) 있으니까요.
2017-07-21 (금) 13:58:27

지금 몇번 해보았는데...

갤러리 최신글 스킨은 위 주소에서 설명한 소스를 넣어도 안되더군요.

질문하신 Basic 스킨은 잘 작동합니다만...

답변을 작성하려면 로그인이 필요합니다.