테스트 사이트 - 개발 중인 베타 버전입니다

그누보드 3차메뉴

· 4년 전 · 5448 · 16

그누보드 3차메뉴

 

/extend/user.config.php파일 또는 임의의 파일(three_menu.config.php)을 생성해서

아래 코드를 삽입후 그누보드 3차메뉴관련 작업을 하시면 

/lib/get_data.lib.php의 get_menu_db()을 수정하지 않아도 됩니다.

 

[code]

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

[/code]

 

또한나 게시판 분류를 메뉴에 출력하고 싶을 경우 아래를 참고해보세요.

[code]

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

[/code]

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 11개

3년 전
이거 어떻게 쓰는건가요

게시글 목록

번호 제목
24318
24317
24315
24309
24294
24293
24277
24262
24260
24253
24251
24236
24233
24228
24226
24221
24214
24203
24201
24199
24196
24195
24194
24192
24191
24187
24185
24183
24172
24168