faq 분류 검색 기능 추가

This commit is contained in:
chicpro
2014-03-14 17:27:54 +09:00
parent 2fbd3e66fa
commit 3c3bfc2b8f
14 changed files with 477 additions and 76 deletions

View File

@ -1,96 +1,104 @@
<?php
include_once('./_common.php');
if (!$fm_id) $fm_id = 1;
//dbconfig파일에 $g5['faq_table'] , $g5['faq_master_table'] 배열변수가 있는지 체크
if( !isset($g5['faq_table']) || !isset($g5['faq_master_table']) ){
die('<meta charset="utf-8">관리자 모드에서 게시판관리->FAQ관리를 먼저 확인해 주세요.');
}
// FAQ MASTER
$sql = " select * from {$g5['faq_master_table']} where fm_id = '$fm_id' ";
$fm = sql_fetch($sql);
$faq_master_list = array();
$sql = " select * from {$g5['faq_master_table']} order by fm_order,fm_id ";
$result = sql_query($sql);
while ($row=sql_fetch_array($result))
{
$key = $row['fm_id'];
if (!$fm_id) $fm_id = $key;
$faq_master_list[$key] = $row;
}
if ($fm_id){
$qstr .= '&amp;fm_id=' . $fm_id; // 마스터faq key_id
}
$fm = $faq_master_list[$fm_id];
if (!$fm['fm_id'])
alert('등록된 내용이 없습니다.');
$g5['title'] = $fm['fm_subject'];
if(G5_IS_MOBILE){
$faq_skin = $config['cf_mobile_faq_skin'];
} else {
$faq_skin = $config['cf_faq_skin'];
}
if(!$faq_skin) $faq_skin = 'basic';
$faq_skin_path = (G5_IS_MOBILE ? G5_MOBILE_PATH : G5_PATH).'/'.G5_SKIN_DIR.'/faq/'.$faq_skin;
$faq_skin_url = (G5_IS_MOBILE ? G5_MOBILE_URL : G5_URL).'/'.G5_SKIN_DIR.'/faq/'.$faq_skin;
$skin_file = $faq_skin_path.'/list.skin.php';
include_once('./_head.php');
?>
<?php
if ($is_admin)
echo '<div class="faq_admin"><a href="'.G5_ADMIN_URL.'/faqmasterform.php?w=u&amp;fm_id='.$fm_id.'" class="btn_admin">FAQ 수정</a></div>';
?>
if(is_file($skin_file)) {
$admin_href = '';
$himg_src = '';
$timg_src = '';
if($is_admin)
$admin_href = G5_ADMIN_URL.'/faqmasterform.php?w=u&amp;fm_id='.$fm_id;
<!-- FAQ 시작 { -->
<?php
$himg = G5_DATA_PATH.'/faq/'.$fm_id.'_h';
if (file_exists($himg))
echo '<div id="faq_himg" class="faq_img"><img src="'.G5_DATA_URL.'/faq/'.$fm_id.'_h" alt=""></div>';
if(!G5_IS_MOBILE) {
$himg = G5_DATA_PATH.'/faq/'.$fm_id.'_h';
if (is_file($himg)){
$himg_src = G5_DATA_URL.'/faq/'.$fm_id.'_h';
}
// 상단 HTML
echo '<div id="faq_hhtml">'.stripslashes($fm['fm_head_html']).'</div>';
?>
$timg = G5_DATA_PATH.'/faq/'.$fm_id.'_t';
if (is_file($timg)){
$timg_src = G5_DATA_URL.'/faq/'.$fm_id.'_t';
}
}
<div id="faq_wrap" class="faq_<?php echo $fm_id; ?>">
<?php // FAQ 목차
$sql = " select * from {$g5['faq_table']}
where fm_id = '$fm_id'
order by fa_order , fa_id ";
$category_href = G5_BBS_URL.'/faq.php';
$category_stx = '';
$faq_list = array();
$stx = trim($stx);
$sql_search = '';
if($stx) {
$sql_search = " and ( INSTR(fa_subject, '$stx') > 0 or INSTR(fa_content, '$stx') > 0 ) ";
$category_stx = '&amp;stx='.$stx;
}
if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$page_rows = G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'];
$sql = " select count(*) as cnt
from {$g5['faq_table']}
where fm_id = '$fm_id'
$sql_search ";
$total = sql_fetch($sql);
$total_count = $total['cnt'];
$total_page = ceil($total_count / $page_rows); // 전체 페이지 계산
$from_record = ($page - 1) * $page_rows; // 시작 열을 구함
$sql = " select *
from {$g5['faq_table']}
where fm_id = '$fm_id'
$sql_search
order by fa_order , fa_id
limit $from_record, $page_rows ";
$result = sql_query($sql);
for ($i=1; $row=sql_fetch_array($result); $i++)
{
if ($i == 1)
{
?>
<section id="faq_list">
<h2><?php echo $g5['title']; ?> 목차</h2>
<ol>
<?php } ?>
<li><a href="#faq_<?php echo $fm_id.'_'.$i; ?>"><?php echo stripslashes($row['fa_subject']); ?></a></li>
<?php }
if ($i > 1) echo '</ol></section>';
?>
<?php // FAQ 내용
$resultb = sql_query($sql);
for ($i=1; $row=sql_fetch_array($resultb); $i++)
{
if ($i == 1)
{
?>
<section id="faq_con">
<h2><?php echo $g5['title']; ?> 내용</h2>
<ol>
<?php } ?>
<li id="faq_<?php echo $fm_id.'_'.$i; ?>">
<h3><?php echo stripslashes($row['fa_subject']); ?></h3>
<div id="con_inner">
<?php echo stripslashes($row['fa_content']); ?>
</div>
<div class="faq_tolist"><a href="#faq_list" class="btn01">FAQ 목차</a></div>
</li>
<?php }
if ($i > 1) echo '</ol></section>';
if ($i == 1) echo '<p>등록된 FAQ가 없습니다.<br><a href="'.G5_ADMIN_URL.'/faqmasterlist.php">FAQ를 새로 등록하시려면 FAQ관리</a> 메뉴를 이용하십시오.</p>';
?>
</div>
<?php
// 하단 HTML
echo '<div id="faq_thtml">'.stripslashes($fm['fm_tail_html']).'</div>';
$timg = G5_DATA_PATH.'/faq/'.$fm_id.'_t';
if (file_exists($timg))
echo '<div id="faq_timg" class="faq_img"><img src="'.G5_DATA_URL.'/faq/'.$fm_id.'_t" alt=""></div>';
?>
<!-- } FAQ 끝 -->
<?php
if ($is_admin)
echo '<div class="faq_admin"><a href="'.G5_ADMIN_URL.'/faqmasterform.php?w=u&amp;fm_id='.$fm_id.'" class="btn_admin">FAQ 수정</a></div>';
while ($row=sql_fetch_array($result)){
$faq_list[] = $row;
}
include_once($skin_file);
} else {
echo '<p>'.str_replace(G5_PATH.'/', '', $skin_file).'이 존재하지 않습니다.</p>';
}
include_once('./_tail.php');
?>