Skip to content
On this page

그누보드 메뉴 만들기

소스 보면서 적용하면 된다. 참고용이다.

php
<divid="header">
<divid="wrap">
<divid="logo"><ahref="<?php echo G5_URL?>"><imgsrc="<?php echo G5_THEME_IMG_URL?>/logo.png"width="150"alt="<?php echo $config['cf_title'];?>"></a></div>
<divid="navi">
<ul>
<?php
$sql="select*
from{$g5['menu_table']}
whereme_use='1'
andlength(me_code)='2'
orderbyme_order,me_id";
$result=sql_query($sql,false);
$gnb_zindex=999;
$menu_datas=array();
  
for($i=0;$row=sql_fetch_array($result);$i++){
    $menu_datas[$i]=$row;
  
    $sql2="select*
    from{$g5['menu_table']}
    whereme_use='1'
    andlength(me_code)='4'
    andsubstring(me_code,1,2)='{$row['me_code']}'
    orderbyme_order,me_id";
    $result2=sql_query($sql2);
    for($k=0;$row2=sql_fetch_array($result2);$k++){
        $menu_datas[$i]['sub'][$k]=$row2;
    }
}
  
  
$i=0;
foreach($menu_datas as $row){
if(empty($row))continue;
$active='';
if($co_id){
if(strpos($row['me_link'],'co_id='.$co_id)!==false){
$active='on';
}
}else
if($bo_table){
if(strpos($row['me_link'],'bo_table='.$bo_table)!==false){
$active.="on";
}
}else{
if(strpos($row['me_link'],$_SERVER['PHP_SELF'])!==false){
$active.="on";
}
}
  
foreach($row['sub']as$j=>$item){
if($co_id){
if(strpos($item['me_link'],'co_id='.$co_id)!==false){
$active='on';
}
}else
if($bo_table){
if(strpos($item['me_link'],'bo_table='.$bo_table)!==false){
$active.="on";
}
}else{
if(strpos($item['me_link'],$_SERVER['PHP_SELF'])!==false){
$active.="on";
}
}
}
?>
<liclass="<?=$active?>">
<ahref="<?php echo $row['me_link'];?>"target="_<?php echo $row['me_target'];?>"><?php echo $row['me_name']?></a>
<?php
$k=0;
foreach((array)$row['sub']as$row2){
  
if(empty($row2))continue;
  
if($k==0)
echo'<ulclass="submenu">'.PHP_EOL;
?>
<li><ahref="<?php echo $row2['me_link'];?>"target="_<?php echo $row2['me_target'];?>"><?php echo $row2['me_name']?></a></li>
<?php
$k++;
}//endforeach$row2
  
if($k>0)
echo'</ul>'.PHP_EOL;
?>
</li>
<?php
$i++;
}//endforeach$row
  
if($i==0){?>
<liclass="gnb_empty">메뉴준비중입니다.
관리자모드&gt;환경설정&gt;메뉴설정에서설정하실수있습니다.</li>
<?php}?>
</ul>
</div>
</div>
</div>
  
  
<script>
$(function(){
$('#navi>ul>li').on('mouseenterkeyup',function(){
$(this).addClass("active").find("ul").stop(true,true).slideDown("fast");
});
  
$('#navi>ul>li>a').on('mouseenterkeyup',function(){
$(this).find("ul").stop(true,true).slideDown("fast");
});
  
$('#navi>ul>li').on('mouseleave',function(){
$(this).removeClass("active").find("ul").stop(true,true).slideUp("fast");
});
});
</script>
  
  
  
<?php if(!defined("_INDEX_")){
  
$bg="";
if($co_id=="company"||$co_id=="location"){
$bg.=G5_THEME_IMG_URL."/company_bg.png";
}elseif($co_id=="summary"||$co_id=="special"||$co_id=="sample"||$co_id=="metal"){
$bg.=G5_THEME_IMG_URL."/tech_bg.png";
}elseif($bo_table){
$bg.=G5_THEME_IMG_URL."/qna_bg.png";
}elseif($co_id=="contact"){
$bg.=G5_THEME_IMG_URL."/cs_bg.png";
}else{
$bg.=G5_THEME_IMG_URL."/qna_bg.png";
}
?>
  
<divclass="sub_page">
<divid="sub_visual"style="background:url('<?=$bg?>');background-size:cover;background-position:50%0;background-repeat:no-repeat;width:100%;height:200px;position:relative;">
<divid="wrap">
<h1><?php echo get_head_title($g5['title']);?></h1>
</div>
</div>
  
<?php if($_SERVER['SCRIPT_NAME']!='/bbs/login.php'){?>
<divid="sub_container">
<divid="wrap">
<ulid="snb">
<li><ahref="<?php echo G5_URL?>"id="snb1"><iclass="fafa-home"></i></a></li>
<liclass="snb_bread">
<?php
if($co_id){
$whereinfo=$co_id;
$codelength=4;
}
if($co_id){
$whereinfo=$co_id;
$codelength=4;
}
if($bo_table){
$whereinfo=$bo_table;
$codelength=4;
}
if($gr_id&&$bo_table==""){
$whereinfo=$gr_id;
$codelength=2;
}
$titledata=sql_fetch("select*from{$g5['menu_table']}whereme_code=(selectsubstring(me_code,1,2)from{$g5['menu_table']}whereme_use='1'andme_linklike'%{$whereinfo}%'andlength(me_code)={$codelength})andlength(me_code)=2orderbyme_order,me_id");
?>
<small><?php echo get_text($titledata['me_name']);?><iclass="fafa-sort-desc"></i></small>
<ulid="snb_submenu">
<?php
$sql="select*from{$g5['menu_table']}whereme_use='1'andlength(me_code)='2'orderbyme_order,me_id";
$result=sql_query($sql,false);
for($i=0;$row=sql_fetch_array($result);$i++){?>
<li><ahref="<?php echo $row['me_link'];?>"target="_<?php echo $row['me_target'];?>"><?php echo $row['me_name']?></a></li>
<?php}?>
</ul>
</li>
<liclass="snb_bread">
<smallclass="active"><?php echo get_head_title($g5['title']);?><iclass="fafa-sort-desc"></i></small>
<?php
$result=sql_query("select*from{$g5['menu_table']}whereme_code=(selectsubstring(me_code,1,2)from{$g5['menu_table']}whereme_use='1'andme_linklike'%{$whereinfo}%'andlength(me_code)={$codelength})orderbyme_order,me_id",false);
for($i=0;$row=sql_fetch_array($result);$i++){
$result2=sql_query("select*from{$g5['menu_table']}whereme_use='1'andlength(me_code)='4'andsubstring(me_code,1,2)='{$row['me_code']}'orderbyme_order,me_id");
  
for($k=0;$row2=sql_fetch_array($result2);$k++){
if($k==0){
echo'<ulid="snb_submenu">'.PHP_EOL;
}
?>
<li><ahref="<?php echo $row2['me_link'];?>"target="_<?php echo $row2['me_target'];?>"><?php echo $row2['me_name']?></a></li>
<?php
}
if($k>0){
echo'</div>'.PHP_EOL;
}
if($k==0){?>
<ul><liclass="gnb_empty">메뉴준비중입니다.</li></ul>
<?php}?>
<?php}?>
</li>
</ul>
</div>
</div>
</div>
<?php}}?>