메뉴 변경 문의
본문
<style>
#hd { z-index:5 !important; }
#topmenu {position:relative; z-index:15; margin:-1px 0 0;height:30px; border-top:0px dotted #dde4e9;border-bottom:0px solid #dde4e9;background:#fff }
#topmenu .wrap {position:absolute; z-index:15; top:-10px; width:600px; left:10%; margin-left:-20px;} /* 가운데 정렬: width:970px; margin:0 auto; */
#topmenu .wrap ul{ float:left; z-index:10; clear:both; margin-right:10px; zoom:1; }
#topmenu .wrap ul:after {display:block; visibility:hidden; clear:both; content:""; }
#topmenu .wrap ul li{float:left;list-style:none;margin:0;padding:0;height:2.95em;}
#topmenu .wrap ul li.active { height:30px; color:#fff; background:#6b9c2a; margin:0 5px; border-radius:5px 5px 5px 5px; }
#topmenu .wrap ul li a{ height:30px; line-height:30px; display:block; cursor:pointer; text-decoration:none; padding:0 20px;color:#2d2d2d; font-size:16px;letter-spacing:0px;display:inline-block; font-weight:bold;} /* 1차메뉴 진하게 */
#topmenu .wrap ul li a:hover{color:#ffff00;}
#topmenu .wrap ul li.active a {color:#ffff00;}
.subBox { position:absolute; z-index:15; top:0px; width:100%; min-height:20px; background-color:#fff; border-bottom:0px solid #5a8d14; display:none; }
.subBox:after {display:block;visibility:hidden;clear:both;content:""}
#topmenu .wrap div.subMenuBox{display:none;position:absolute;left:0;top:25px; height:20px; line-height:20px; margin:0;padding:0; }
#topmenu .wrap div.subMenuBox ul,#topmenu .wrap div.subMenuBox ul li{margin:0;padding:0;background:none}
#topmenu .wrap div.subMenuBox ul li {height:30px;}
#topmenu .wrap div.subMenuBox ul li a{margin:0;padding:0 14px; font-size:16px; letter-spacing:-1px;color:#5d5d5d;height:30px;line-height:30px;display:inline-block;font-weight:bold;}
#topmenu .wrap div.subMenuBox ul li a:hover{color:#67932b; font-weight:bold; }
#topmenu .wrap div.subMenuBox ul li a.active,#topmenu .wrap div.subMenuBox ul li a:active{color:#466022;}
#topmenu .wrap div.subMenuBox ul li.on a{text-decoration:underline;}
#topmenu .wrap div.subMenuBox a:focus, #mysubmenu li.leftmenu_s a:hover { color:#F7082F;}
</style>
<script type="text/javascript">
jQuery(function($){
$.fn.Mmenu = function(options) {
var opts = $.extend(options);
var Mmenu = $(this);
var MmenuList = Mmenu.find('>ul>li');
var subMenuBox = Mmenu.find('.subMenuBox');
var subMenuBoxList = subMenuBox.find('>ul>li');
var menuwidth = $(this).width();
function showMenu() {
t = $(this).parent('li');
subwidth = t.find('.subMenuBox').width();
if (!t.hasClass('active')) {
MmenuList.removeClass('active');
t.addClass('active');
subMenuBox.hide();
if (t.position().left + t.find('.subMenuBox').width() > menuwidth) {
t.find('.subMenuBox').show().css({left:subwidth}).animate({left: (menuwidth - subwidth)-10}, 400);
} else {
t.find('.subMenuBox').show().css({left:subwidth}).animate( { left: t.position().left}, 400 );
}
}
}
function hideMenu() {
MmenuList.removeClass('active');
subMenuBox.hide();
activeMenu();
}
function activeMenu() {
if(opts.ok1) {
t = MmenuList.eq(opts.ok1-1);
subwidth = t.find('.subMenuBox').width();
t.addClass('active');
if (t.position().left + t.find('.subMenuBox').width() > menuwidth) {
t.find('.subMenuBox').show().css({left:subwidth}).animate({left: (menuwidth - subwidth)-10}, 400);
} else {
t.find('.subMenuBox').show().css({left:subwidth}).animate( { left: t.position().left}, 400 );
}
}
}
return this.each(function() {
activeMenu();
MmenuList.find('>a').mouseover(showMenu).focus(showMenu);
Mmenu.mouseleave(hideMenu);
});
}
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$('#topmenu .wrap').Mmenu({ ok1: 0 });
});
$('div.menubg a').click(function(){
var bgBgCol = jQuery(this).attr('href');
var menuHeight = jQuery(this).attr('mheight');
$('div.menubg a').removeClass('current');
$(this).addClass('current');
$('#topmenu,,.wrap,#topmenu a.active,#mainmenu li.ok1').height(menuHeight);
$('#topmenu .wrap').height(menuHeight + 30);
$('#topmenu .wrap div.subMenuBox').css({top:menuHeight+'px'}).height(30);
$('#menubgVal').val(bgBgCol);
$('#topmenuHeight').val(menuHeight);
return false;
});
</script>
<script type="text/javascript">
//네비게이션 레이아웃 적용
$(document).ready(function(){
$("nav#topmenu a").mouseenter(function() {
if($("div#subBox").css("display") != "block"){
$("div#subBox").slideDown();
}
});
$("nav#topmenu").mouseleave(function() {
$("div#subBox").hide();
});
})
</script>
<nav id="topmenu">
<div id="subBox" class="subBox"></div>
<div class="wrap" id="Mmenu">
<ul>
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '2'
order by me_order, me_id ";
$result = sql_query($sql, false);
$gnb_zindex = 999; // gnb_1dli z-index 값 설정용
//echo "<li><a href='/'>HOME</a></li>";
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
<li class="ok1">
<a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>"><?php echo $row['me_name'] ?></a>
<div class="subMenuBox">
<?php
$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++) {
if($k == 0)
echo '<ul>'.PHP_EOL;
?>
<li><a href="<?php echo $row2['me_link']; ?>" target="_<?php echo $row2['me_target']; ?>"><?php echo $row2['me_name'] ?></a></li>
<?php
}
if($k > 0)
echo '</ul>'.PHP_EOL;
?>
</div>
<div class="clear"></div>
</li>
<?php
}
if ($i == 0) { ?>
<li id="gnb_empty">메뉴 준비 중입니다.<?php if ($is_admin) { ?> <br><a href="<?php echo G5_ADMIN_URL; ?>/menu_list.php">관리자모드 > 환경설정 > 메뉴설정</a>에서 설정하실 수 있습니다.<?php } ?></li>
<?php } ?>
</ul>
</div>
</nav>
----------------------------
현재 위 소스는 1차와 2차 메뉴만 나오게 하였는데-
이를 1차대신 2차로 2차대신3차로 변형 하려 했는데 초보라 어렵네요
고수님 도와 주세요.
!-->답변 1
and length(me_code) = '2'
me_code 의 길이가 2자리수이면 1차, 4자리수이면 2차로 나오고있는걸로 보입니다
3차의 me_code를 6자리로 세팅하시고, 아래와 같이 수정하시면 될거같습니다.
만약 2차 메뉴의 me_code가 2010 이면 3차는 201010,201030,201040 이런식으로요~
<?php
<?php
$sql = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '4'
order by me_order, me_id ";
$result = sql_query($sql, false);
$gnb_zindex = 999; // gnb_1dli z-index 값 설정용
//echo "<li><a href='/'>HOME</a></li>";
for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
<li class="ok1">
<a href="<?php echo $row['me_link']; ?>" target="_<?php echo $row['me_target']; ?>"><?php echo $row['me_name'] ?></a>
<div class="subMenuBox">
<?php
$sql2 = " select *
from {$g5['menu_table']}
where me_use = '1'
and length(me_code) = '6'
and substring(me_code, 1, 4) = '{$row['me_code']}'
order by me_order, me_id ";
$result2 = sql_query($sql2);
for ($k=0; $row2=sql_fetch_array($result2); $k++) {
if($k == 0)
echo '<ul>'.PHP_EOL;
?>
답변을 작성하시기 전에 로그인 해주세요.