그누보드 3차메뉴 정보
그누보드 3차메뉴본문
그누보드 3차메뉴
/extend/user.config.php파일 또는 임의의 파일(three_menu.config.php)을 생성해서
아래 코드를 삽입후 그누보드 3차메뉴관련 작업을 하시면
/lib/get_data.lib.php의 get_menu_db()을 수정하지 않아도 됩니다.
add_replace('get_menu_db', 'get_three_menu_db', 10, 1);
function get_three_menu_db($use_mobile=0, $is_cache=false){
global $g5;
static $cache = array();
$cache = run_replace('get_three_menu_db_cache', $cache, $use_mobile, $is_cache);
$key = md5($use_mobile);
if( $is_cache && isset($cache[$key]) ){
return $cache[$key];
}
$where = $use_mobile ? "me_mobile_use = '1'" : "me_use = '1'";
if( !($cache[$key] = run_replace('get_three_menu_db', array(), $use_mobile)) ){
$sql = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$row['ori_me_link'] = $row['me_link'];
$row['me_link'] = short_url_clean($row['me_link']);
$row['sub'] = isset($row['sub']) ? $row['sub'] : array();
$cache[$key][$i] = $row;
$sql2 = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '4'
and substring(me_code, 1, 2) = '{$row['me_code']}'
order by me_order, me_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
$row2['ori_me_link'] = $row2['me_link'];
$row2['me_link'] = short_url_clean($row2['me_link']);
$row2['sub'] = isset($row2['sub']) ? $row2['sub'] : array();
$cache[$key][$i]['sub'][$k] = $row2;
$sql3 = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '6'
and substring(me_code, 1, 4) = '{$row2['me_code']}'
order by me_order, me_id ";
$result3 = sql_query($sql3);
for ($s=0; $row3=sql_fetch_array($result3); $s++) {
$row3['ori_me_link'] = $row3['me_link'];
$row3['me_link'] = short_url_clean($row3['me_link']);
$cache[$key][$i]['sub'][$k]['sub'][$s] = $row3;
}
}
}
}
return $cache[$key];
}
또한나 게시판 분류를 메뉴에 출력하고 싶을 경우 아래를 참고해보세요.
add_replace('get_menu_db', 'get_three_menu_db', 10, 1);
function get_three_menu_db($use_mobile=0, $is_cache=false){
global $g5;
static $cache = array();
$cache = run_replace('get_three_menu_db_cache', $cache, $use_mobile, $is_cache);
$key = md5($use_mobile);
if( $is_cache && isset($cache[$key]) ){
return $cache[$key];
}
$where = $use_mobile ? "me_mobile_use = '1'" : "me_use = '1'";
if( !($cache[$key] = run_replace('get_three_menu_db', array(), $use_mobile)) ){
$sql = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
for ($i=0; $row=sql_fetch_array($result); $i++) {
$row['ori_me_link'] = $row['me_link'];
$row['me_link'] = short_url_clean($row['me_link']);
$row['sub'] = isset($row['sub']) ? $row['sub'] : array();
$cache[$key][$i] = $row;
$bo2_sql = " select bo_table, bo_use_category, bo_category_list, bo_count_write, bo_count_comment from {$g5['board_table']} where find_in_set(bo_table,'{$row['me_pid']}') ";
$bo2 = sql_fetch($bo2_sql);
if($bo2['bo_use_category']) {
$row2 = explode("|", $bo2['bo_category_list']);
for ($s=0; $s<count($row2); $s++) {
if(!trim($row2[$s])) continue;
$row2['ori_me_link'] = G5_BBS_URL.'/board.php?bo_table='.$bo2['bo_table'].'&sca='.$row2[$s];
$row2['me_link'] = short_url_clean($row2['ori_me_link']);
$row2['me_name'] = $row2[$s];
$row2['me_pid'] = $row2[$s];
$row2['me_target'] = 'self';
$row2['me_order'] = 0;
$row2['me_use'] = 1;
$row2['me_mobile_use'] = 1;
$row2['bo_count_write'] = $bo2['bo_count_write'];
$row2['bo_count_comment'] = $bo2['bo_count_comment'];
$cache[$key][$i]['sub'][$s] = $row2;
}
}else{
$sql2 = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '4'
and substring(me_code, 1, 2) = '{$row['me_code']}'
order by me_order, me_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
$row2['ori_me_link'] = $row2['me_link'];
$row2['me_link'] = short_url_clean($row2['me_link']);
$row2['sub'] = isset($row2['sub']) ? $row2['sub'] : array();
$cache[$key][$i]['sub'][$k] = $row2;
$bo_sql = " select bo_table, bo_use_category, bo_category_list, bo_count_write, bo_count_comment from {$g5['board_table']} where find_in_set(bo_table,'{$row2['me_pid']}') ";
$bo = sql_fetch($bo_sql);
if($bo['bo_use_category']) {
$row3 = explode("|", $bo['bo_category_list']);
for ($s=0; $s<count($row3); $s++) {
if(!trim($row3[$s])) continue;
$row3['ori_me_link'] = G5_BBS_URL.'/board.php?bo_table='.$bo['bo_table'].'&sca='.$row3[$s];
$row3['me_link'] = short_url_clean($row3['ori_me_link']);
$row3['me_name'] = $row3[$s];
$row3['me_pid'] = $row3[$s];
$row3['me_target'] = 'self';
$row3['me_order'] = 0;
$row3['me_use'] = 1;
$row3['me_mobile_use'] = 1;
$row3['bo_count_write'] = $bo['bo_count_write'];
$row3['bo_count_comment'] = $bo['bo_count_comment'];
$cache[$key][$i]['sub'][$k]['sub'][$s] = $row3;
}
}else{
$sql3 = " select *
from {$g5['menu_table']}
where $where
and length(me_code) = '6'
and substring(me_code, 1, 4) = '{$row2['me_code']}'
order by me_order, me_id ";
$result3 = sql_query($sql3);
for ($s=0; $row3=sql_fetch_array($result3); $s++) {
$row3['ori_me_link'] = $row3['me_link'];
$row3['me_link'] = short_url_clean($row3['me_link']);
$cache[$key][$i]['sub'][$k]['sub'][$s] = $row3;
}
}
}
}
}
}
return $cache[$key];
}
추천
16
16
댓글 16개
유용한 정보 감사드립니다.
감사드립니다.
감사합니다.
감사합니다.
적용해보겠습니다.^^
적용해보겠습니다.^^
감사합니다.
수고하셨습니다.
수고햐셨어요!
감사합니다.
감사합니다.
감사합니다
Good
감사합니다
이거 어떻게 쓰는건가요