그누보드 3차메뉴

· 2021-06-29 (화) 12:39:11 · 7549 · 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개

2021-06-29 (화) 13:41:48
유용한 정보 감사드립니다.
감사드립니다.
감사합니다.
감사합니다.
적용해보겠습니다.^^
2021-06-30 (수) 01:00:42
감사합니다.
2021-06-30 (수) 19:06:20
수고하셨습니다.
2021-07-07 (수) 15:07:01
수고햐셨어요!
감사합니다.
감사합니다
2021-12-11 (토) 21:18:41
Good
감사합니다
이거 어떻게 쓰는건가요
댓글을 작성하시려면 로그인이 필요합니다.

그누보드5 팁자료실

2,788건
+
제목 글쓴이 날짜 조회
21-07-23 조회 6,905
21-07-23 조회 5,463
21-07-16 조회 6,974
21-07-14 조회 5,776
21-07-14 조회 4,413
21-07-12 조회 5,061
21-07-12 조회 4,869
21-07-09 조회 5,564
21-07-07 조회 4,862
21-07-06 조회 5,355
21-07-05 조회 6,214
21-07-05 조회 5,904
21-07-01 조회 5,894
21-06-30 조회 5,143
21-06-29 조회 8,143
21-06-29 조회 6,536
21-06-29 조회 7,550
21-06-29 조회 6,486
21-06-27 조회 6,642
21-06-24 조회 7,793
21-06-24 조회 6,706
21-06-24 조회 5,492
21-06-23 조회 9,306
21-06-22 조회 7,289
21-06-22 조회 4,490
21-06-20 조회 6,793
21-06-20 조회 4,743
21-06-19 조회 5,804
21-06-17 조회 5,584
21-06-16 조회 6,918