안녕하세요 그누보드5 초보입문자입니다 ㅠ_ㅠ
이번에 최신글 앞에 가져오면서
일반 게시글은 게시판 추가할때 table명을 입력을 하자나요
추가된 테이블명을 shop_basic 뒤에 써주는데
이렇게 ---> <?php echo latest('shop_basic', 'notice', 6, 20); ?>
하지만 그누보드 자체에 1:1문의가 있는거 다 아시죠?ㅠㅠ
관리자에서 1:1문의는 게시판처럼 table명이 없어서
id명 하는곳에 무엇을 넣어야는지 몰라서 지금 패닉상태입니다 ㅠㅠ
혹시 아시는 능력자분들 있으시면 댓글 좀 달아주세요 부탁드립니다 ㅎ
답변 2개 / 댓글 3개
1:1 문의 게시판은 작성자와 관리자만 열람이 가능하도록 제한하는 특징이 있습니다.
아래 라이브러리 파일과 스킨파일을 정해진 위치에 올리고 테스트 해보세요.
미리보기는 http://jemg.co.kr/ 오른쪽 하단에 1:1문의 입니다.
주)스킨 파일은 부트스트랩 코딩이라 미리보기와 다릅니다. 꼭 본인에 맞게 손보셔야 합니다.
영카트 팁란에도 올려 두었습니다.
----------------------------------------------------------
1. 스킨파일 /skin/latest/qa_basic_bs/latest.skin.php 에 위치하도록 폴더를 만들고 파일명도 맞춰서 업로드 하세요.
<?phpif (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가// print_r2($list);// 1:1 문의 최신글 - extend/qalatest.lib.php?><ul class="list-group tooltip-qala"> <a class="list-group-item" href="<?php echo G5_BBS_URL ?>/qalist.php"><b><?php echo $qa_subject; ?></b><span class="pull-right" href="<?php echo G5_BBS_URL ?>/qalist.php">more</span></a> <?php for ($i=0; $i<count($list); $i++) { ?> <li class="list-group-item" > <span class="subject"><a href="<?php echo $list[$i]['view_href']; ?>"><?php echo $list[$i]['qa_subject']; ?></a></span> <span class="name"><?php echo $list[$i]['name']; ?></span> <span class="time <?php echo ($list[$i]['qa_status'] ? 'txt_done' : 'txt_rdy'); ?>" data-toggle="tooltip" data-placement="top" title="<?php echo $list[$i]['qa_datetime']; ?>"><?php echo $list[$i]['date']; ?> [<?php echo ($list[$i]['qa_status'] ? '답변완료' : '답변대기'); ?>]</span> </li> <?php } ?> <?php if (count($list) == 0) { //게시물이 없을 때 ?> <li class="list-group-item"> <span class="subject"><a href="<?php echo G5_BBS_URL ?>/login.php" title="로그인 페이지로 이동">로그인 회원님 본인의 게시물만 보입니다.</a></span> </li> <?php } ?></ul>
2. 라이브러리 파일 qalatest.lib.php 는 /extend/하위에 넣어주세요.
<?phpif (!defined('_GNUBOARD_')) exit;// 1:1 문의 최신글 추출 - /skin/latest/qa_basic_bs// $cache_time 캐시 갱신시간function qalatest($skin_dir='', $qa_board, $rows=10, $subject_len=40, $cache_time=1, $options=''){ global $config, $member, $g5, $is_admin, $is_member; $qaconfig = get_qa_config(); $qa_subject = $qaconfig['qa_title']; // $qa_subject = "1:1 질문답변"; $qa_board = $g5['qa_content_table']; if (!$skin_dir) $skin_dir = 'qa_basic_bs'; // 강제지정 if(G5_IS_MOBILE) { $qa_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; $qa_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir; } else { $qa_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir; $qa_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir; } $cache_fwrite = false; if(G5_USE_CACHE) { $cache_file = G5_DATA_PATH."/cache/latest-qa-{$qa_board}-{$skin_dir}-{$rows}-{$subject_len}.php"; if(!file_exists($cache_file)) { $cache_fwrite = true; } else { if($cache_time > 0) { $filetime = filemtime($cache_file); if($filetime && $filetime < (G5_SERVER_TIME - 3600 * $cache_time)) { @unlink($cache_file); $cache_fwrite = true; } } if(!$cache_fwrite) include($cache_file); } } if(!G5_USE_CACHE || $cache_fwrite) { $sql_common = " from {$qa_board} "; $sql_search = " where qa_type = '0' "; if(!$is_admin){ $sql_search .= " and mb_id = '{$member['mb_id']}' "; } $sql_order = " order by qa_num "; $sql = " select * $sql_common $sql_search $sql_order limit 0, $rows "; $result = sql_query($sql); $list = array(); $subject_len = G5_IS_MOBILE ? $qaconfig['qa_mobile_subject_len'] : $qaconfig['qa_subject_len']; for($i=0; $row=sql_fetch_array($result); $i++) { // $list[$i] = get_list($row, $qa_board, $qa_skin_url, $subject_len); $list[$i] = $row; $list[$i]['category'] = get_text($row['qa_category']); $list[$i]['subject'] = conv_subject($row['qa_subject'], $subject_len, '…'); if ($stx) { $list[$i]['subject'] = search_font($stx, $list[$i]['subject']); } $list[$i]['view_href'] = G5_BBS_URL.'/qaview.php?qa_id='.$row['qa_id'].$qstr; $list[$i]['icon_file'] = ''; if(trim($row['qa_file1']) || trim($row['qa_file2'])) $list[$i]['icon_file'] = '<img src="'.$qa_skin_url.'/img/icon_file.gif">'; $list[$i]['name'] = get_text($row['qa_name']); $list[$i]['date'] = substr($row['qa_datetime'], 2, 8); $list[$i]['num'] = $num - $i; } if($cache_fwrite) { $handle = fopen($cache_file, 'w'); $cache_content = "<?php\nif (!defined('_GNUBOARD_')) exit;\n\$qa_subject='".$qa_subject."';\n\$list=".var_export($list, true)."?>"; fwrite($handle, $cache_content); fclose($handle); } } /* // 같은 스킨은 .css 를 한번만 호출한다. if (!in_array($skin_dir, $css) && is_file($qa_skin_path.'/style.css')) { echo '<link rel="stylesheet" href="'.$qa_skin_url.'/style.css">'; $css[] = $skin_dir; } */ ob_start(); include $qa_skin_path.'/latest.skin.php'; $content = ob_get_contents(); ob_end_clean(); return $content;}?>
3. 최신글을 불러올때는 원하는 위치에 아래와 같이 호출 합니다.
<?php echo qalatest('qa_basic_bs','g5_qa_content_table', 5, 50); ?>
답변에 대한 댓글 2개
다른 파일에 같은 이름의 펑션이 있어서 중복되면 에러날 수 있습니다.
그때는 펑션이름을 다름이름으로(예: aaa) 바꾸고 호출할때 아래처럼 하세요.
라이브러리 수정.
function aaa($skin_dir='', $qa_board, $rows=10, $subject_len=40, $cache_time=1, $options='')
~~~~~
호출.
<?php echo aaa('qa_basic_bs','g5_qa_content_table', 5, 50); ?>
먼저 저도 그누5는 파악중이라는점 말씀드립니다.
테스트 안해본것이고 안될수도 잇어요.
/lib/latest.lib.php
맨끝 ?> 이거 바로 위에 추가
// 1:1 추출
function latest($skin_dir='', $rows=10, $subject_len=40)
{
global $g5;
//static $css = array();
if (!$skin_dir) $skin_dir = 'basic';
if(G5_IS_MOBILE) {
$latest_skin_path = G5_MOBILE_PATH.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
$latest_skin_url = G5_MOBILE_URL.'/'.G5_SKIN_DIR.'/latest/'.$skin_dir;
} else {
$latest_skin_path = G5_SKIN_PATH.'/latest/'.$skin_dir;
$latest_skin_url = G5_SKIN_URL.'/latest/'.$skin_dir;
}
$list = array();
$sql = " select * from g5_qa_content where qa_type='0' order by qa_datetime limit 0, {$rows} ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {
$list[$i][subject] = conv_subject($row['qa_subject'], $subject_len, '…'); //글제목
$list[$i][content] = $row['qa_content']; //글내용
$list[$i][name] = get_sideview($row['mb_id'], $row['qa_name'], $row['qa_email'], ''); //글쓴이
$list[$i][status] = $row['qa_status']; //답변상태 0은 답변완료,1은 답변대기
$list[$i][datatime] = $row['qa_datatime']; //글쓴날짜
$list[$i][href] = $G5_BBS_PATH."/qaview.php?qa_id=".$row['qa_id']; //링크
}
ob_start();
include $latest_skin_path.'/latest.skin.php';
$content = ob_get_contents();
ob_end_clean();
return $content;
}
스킨상에서 표시하는건 위에 빨간색 표시한거 쓰시면 되구요.
인덱스에서 불러오기는
<?
//스킨,불러올수,제목짤림
php echo latest('shop_basic', 6, 20);
?>
하심 될듯........
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.
그리고 최신글 불러올때요 qalatest는 latest처럼 폴더명이죠? 근데 qalatest를 만든적이 없는데. 상관 없는건가요?