메뉴고수님 도와주세욤~

메뉴고수님 도와주세욤~

QA

메뉴고수님 도와주세욤~

본문

대메뉴를 누르면 서브가 나오게되어있는데 대메뉴에는 링크가 안걸려서 클릭이 안됩니다 ㅠㅠ

대메뉴도 링크걸리게 할수있나요? 테마를 받은거라서 수정이 힘드네요..

 

 

function cm_menu_is_active($active_checks, $url)
{
    foreach($active_checks as $key=>$value) {
        if(!$value) continue;
        if(preg_match('/'.$key.'='.$value.'/', $url)) return true;
    }
    return false;
}

for ($i=0; $row=sql_fetch_array($result); $i++) {
    $menu_item = array('url' => $row['me_link'], 'target' => $row['me_target'], 'name' => $row['me_name'], 'is_active'=>false, 'sub_menu' => array());
    if(cm_menu_is_active($active_checks, $row['me_link'])) {
        $menu_item['is_active'] = true;
    }
    $sql2 = " select * from {$g5['menu_table']} where me_use = '1' 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++) {
        $sm = array('url' => $row2['me_link'], 'target' => $row2['me_target'], 'is_active'=>false, 'name' => $row2['me_name']);
        if(cm_menu_is_active($active_checks, $row2['me_link'])) {
            $menu_item['is_active'] = true;
            $sm['is_active'] = true;
        }
        array_push($menu_item['sub_menu'], $sm);
    }
    array_push($menus, $menu_item);
}
?>

 

 

============메뉴부분

 

                <?php

                foreach($menus as $menu_item) {

                    $is_active_menu = ($menu_item['is_active'] ? 'active' : '');

                    if(empty($menu_item['sub_menu'])) {
                          
                        echo '<li class="nav-item"><a class="nav-link" href="'.$menu_item['url'].'" target="_'.$menu_item['target'].'">'.$menu_item['name'].'</a></li>'.PHP_EOL;
                        } else {
                         echo '<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'.$menu_item['name'].'</a>'.PHP_EOL;
       echo '<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">'.PHP_EOL;
                            foreach($menu_item['sub_menu'] as $sub_menu) {
                                echo '<a class="dropdown-item" href="'.$sub_menu['url'].'" target="_'.$sub_menu['target'].'">'.$sub_menu['name'].'</a>'.PHP_EOL;
                            }
                            echo '</div>'.PHP_EOL;
                            echo '</li>'.PHP_EOL;
                        }
                    }
                    ?>

이 질문에 댓글 쓰기 :

답변 1

지금 코드를 보니 서브메뉴가 없으면 대메뉴에 링크가 생성되고 서브메뉴가 있으면 대메뉴에 링크가 없어지게 코드가 되어 있습니다.

 

if문을 아예 제거해서 계속나오게 하는 방법이랑 또는

 

<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'.$menu_item['name'].'</a>'.PHP_EOL;

이 부분을

<a class="nav-link dropdown-toggle" href="'.$menu_item['url'].'" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">'.$menu_item['name'].'</a>'.PHP_EOL;

이와 같이 수정하면 될거 같습니다.

 

답변을 작성하시기 전에 로그인 해주세요.
전체 111
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT