특정 그룹내 게시판 목록과 분류(숨김) 세로배열 - 마니아님 요청 정보
특정 그룹내 게시판 목록과 분류(숨김) 세로배열 - 마니아님 요청본문
예전에 ak47님께서 제게 보여주셨던 메뉴를 같이 벌레잡기 했던 소스코드입니다.
-새로고침해도 기존에 열려있는 게시판을 기억하는 똑똑한(?) 특징이 있습니다.
미리보기 http://gnusr.com/g4/gnusr/test/menu_test.php 에서 _test_menu_ak47
요청에 의해 올리지만 중복여부를 확인하지 못했습니다.(죄송합니다)
소스코드에서 $ca_id로 검색후 $gr_id 혹은 그룹아이디로 대체해주세요.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<!-- 디자인 부분 -->
<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 2px;
background-color:#CDCDCD;
color:#000000;
width:190px;
padding:5px;
text-align:left;
font-weight:bold;
border:0px solid #000000;
}
.submenu{ padding:5px; margin-left:35px; text-align:left; }
</style>
<script type="text/javascript">
var persistmenu="yes"
var persisttype="sitewide"
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
// 메뉴전환
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu")
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
// 쿠키
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}
// 기존메뉴상태 보존
function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}
if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction
if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
</script>
<?
global $g4;
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = '$ca_id' order by bo_subject ";
/*
//$sql = " select * from $g4[board_table] where bo_list_level = '1' order by bo_subject ";
$sql = " select * from $g4[board_table]
where gr_id <> 'work'
and gr_id <> 'montessori'
and gr_id <> 'etc'
and gr_id <> 'link'
order by bo_subject ";
*/
$result = sql_query($sql);
echo "<div id='masterdiv' align=center>";
$k="";
while ($row = mysql_fetch_array($result)) {
$k=$k+1;
if ($row[bo_use_category]==0) {
echo <<<HEREDOC
<div class="menutitle" onClick="location.href='$g4[bbs_path]/board.php?bo_table=$row[bo_table]'"> {$row[bo_subject]}</div>
<span class="submenu" id="sub$k"></span>
HEREDOC;
continue;
}
else {
echo <<<HEREDOC
<div class="menutitle" onclick="SwitchMenu('sub$k')"> {$row[bo_subject]}</div>
<span class="submenu" id="sub$k">
HEREDOC;
$arr = explode("|", $row[bo_category_list]); // 구분자가 | 로 되어 있음
echo <<<HEREDOC
<A HREF="$g4[bbs_path]/board.php?bo_table=$row[bo_table]&sca=">전체분류</A><br>
HEREDOC;
for ($i=0; $i<count($arr); $i++)
if (trim($arr[$i])) {
echo <<<HEREDOC
<A HREF="$g4[bbs_path]/board.php?bo_table=$row[bo_table]&sca=$arr[$i]">{$arr[$i]}</A><br>
HEREDOC;
}
echo "</span>";
}
}
echo "</div> ";
mysql_free_result($result);
?>
-새로고침해도 기존에 열려있는 게시판을 기억하는 똑똑한(?) 특징이 있습니다.
미리보기 http://gnusr.com/g4/gnusr/test/menu_test.php 에서 _test_menu_ak47
요청에 의해 올리지만 중복여부를 확인하지 못했습니다.(죄송합니다)
소스코드에서 $ca_id로 검색후 $gr_id 혹은 그룹아이디로 대체해주세요.
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
?>
<!-- 디자인 부분 -->
<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 2px;
background-color:#CDCDCD;
color:#000000;
width:190px;
padding:5px;
text-align:left;
font-weight:bold;
border:0px solid #000000;
}
.submenu{ padding:5px; margin-left:35px; text-align:left; }
</style>
<script type="text/javascript">
var persistmenu="yes"
var persisttype="sitewide"
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}
// 메뉴전환
function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span");
if(el.style.display != "block"){
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu")
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}
// 쿠키
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}
// 기존메뉴상태 보존
function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}
if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction
if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate
</script>
<?
global $g4;
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = '$ca_id' order by bo_subject ";
/*
//$sql = " select * from $g4[board_table] where bo_list_level = '1' order by bo_subject ";
$sql = " select * from $g4[board_table]
where gr_id <> 'work'
and gr_id <> 'montessori'
and gr_id <> 'etc'
and gr_id <> 'link'
order by bo_subject ";
*/
$result = sql_query($sql);
echo "<div id='masterdiv' align=center>";
$k="";
while ($row = mysql_fetch_array($result)) {
$k=$k+1;
if ($row[bo_use_category]==0) {
echo <<<HEREDOC
<div class="menutitle" onClick="location.href='$g4[bbs_path]/board.php?bo_table=$row[bo_table]'"> {$row[bo_subject]}</div>
<span class="submenu" id="sub$k"></span>
HEREDOC;
continue;
}
else {
echo <<<HEREDOC
<div class="menutitle" onclick="SwitchMenu('sub$k')"> {$row[bo_subject]}</div>
<span class="submenu" id="sub$k">
HEREDOC;
$arr = explode("|", $row[bo_category_list]); // 구분자가 | 로 되어 있음
echo <<<HEREDOC
<A HREF="$g4[bbs_path]/board.php?bo_table=$row[bo_table]&sca=">전체분류</A><br>
HEREDOC;
for ($i=0; $i<count($arr); $i++)
if (trim($arr[$i])) {
echo <<<HEREDOC
<A HREF="$g4[bbs_path]/board.php?bo_table=$row[bo_table]&sca=$arr[$i]">{$arr[$i]}</A><br>
HEREDOC;
}
echo "</span>";
}
}
echo "</div> ";
mysql_free_result($result);
?>
추천
2
2
댓글 8개
감사합니다~
좋군요~
이것도... 플록님 감사합니다.
이런 문구가 뜨네요
Parse error: syntax error, unexpected T_SL, expecting ',' or ';' in F:\RWAPM\www\g4\menu.php on line 124
왜그런가요...........
Parse error: syntax error, unexpected T_SL, expecting ',' or ';' in F:\RWAPM\www\g4\menu.php on line 124
왜그런가요...........
HEREDOC 관련 'HEREDOC 공백'으로 검색해보시면 g6man님의 체크내용에서,,
<<<HEREDOC 에서 HEREDOC 뒤에 모든 공백 및 탭을 제거하시고
HEREDOC; 이전의 공백 및 탭 그리고 ;이후의 공백 및 탭을 제거하고 다시 테스트해보세요
참고하세요.
<<<HEREDOC 에서 HEREDOC 뒤에 모든 공백 및 탭을 제거하시고
HEREDOC; 이전의 공백 및 탭 그리고 ;이후의 공백 및 탭을 제거하고 다시 테스트해보세요
참고하세요.
알려준 데로 수정하니깐 에러 문구는 뜨지가 않네요
그런데 화면이 아무것도 출력이 되지가 않네요.
게시판에서 다른것을 설정해야 하난요 $ca_id도 수정했는데
html소스를 보면
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type
content="text/html; charset=ks_c_5601-1987"></HEAD>
<BODY></BODY></HTML>
이렇게만 출력이 되네요
그런데 화면이 아무것도 출력이 되지가 않네요.
게시판에서 다른것을 설정해야 하난요 $ca_id도 수정했는데
html소스를 보면
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type
content="text/html; charset=ks_c_5601-1987"></HEAD>
<BODY></BODY></HTML>
이렇게만 출력이 되네요
그룹값이 없는 경우로 보입니다.
쿼리문에서 '그룹아이디' 대체후 기존의 헤더나 index화일에 붙여 테스트 해보세요.
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = '그룹아이디' order by bo_subject ";
소스 건드리지 않은 적용예 입니다.
$sql = " select * from $g4[board_table]
where gr_id = 'test' order by bo_subject ";
http://www.gnusr.com/gnu/tt.php
쿼리문에서 '그룹아이디' 대체후 기존의 헤더나 index화일에 붙여 테스트 해보세요.
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = '그룹아이디' order by bo_subject ";
소스 건드리지 않은 적용예 입니다.
$sql = " select * from $g4[board_table]
where gr_id = 'test' order by bo_subject ";
http://www.gnusr.com/gnu/tt.php
<?
global $g4;
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = 'user' order by bo_subject ";
/*
이렇게 했는데요...
게시판에서나 아니면 그룹에서 따로 설정해야하는게 있나요
global $g4;
//해당그룹만
$sql = " select * from $g4[board_table]
where gr_id = 'user' order by bo_subject ";
/*
이렇게 했는데요...
게시판에서나 아니면 그룹에서 따로 설정해야하는게 있나요