공지체크관련 문의드립니다.
본문
<?php if($is_notice) { ?>
<?php }else{ ?>
<hr />
<div style="float:left;"> * 예약자성함 : </div> <div style="float:left;"> <?php echo $view['wr_1'] ?> </div>
<div style="clear:left;float:left;"> * 연락처 : </div> <div style="float:left;"> <?php echo $view['wr_2'] ?> </div>
<div style="clear:left;float:left;"> * 촬영/본식날짜 : </div> <div style="float:left;"> <?php echo $view['wr_3'] ?> </div>
<div style="clear:left;float:left;"> * 촬영/본식시간 : </div> <div style="float:left;"> <?php echo $view['wr_4'] ?> </div>
<div style="clear:left;float:left;"> * 촬영상품 : </div> <div style="float:left;"> <?php echo $view['wr_5'] ?> </div>
<div style="clear:left;"></div>
<hr />
<?php } ?>
게시판내용보기 입니다.
여분필드를 추가 해서 view.php 페이지에 뿌려지게 만들었습니다.
이 부분을 공지 일때는 나오지 않게 하려고
<?php if($is_notice) { ?>
이 구문을 사용하였습니다.
공지 여부를 체크하는것이 이구문이 아닌지요?
아니면 어떤 구문을 넣어야 공지 여부에 따라 출력할 수 있을까요?
!-->답변 3
아래와 같이 해주세요.
<?php if($is_notice) { ?>
을
<?php if ($view['is_notice']) { ?>
로 변경해주세요.
공지라는것은 흠,,,
echo $board['bo_notice']
이러게 해야되는데
좀 부연 설명 을 하자면
lib/common.lib.php
안에 보면요
$board_notice = array_map('trim', explode(',', $board['bo_notice']));
$list['is_notice'] = in_array($list['wr_id'], $board_notice);
소그가 있습니다
좀 설명 을하자면
$board['bo_notice'] 안에 내용은 1, 2, 3, 33 등등 공지사항으로 채크되어 있는
모든 게시물의 번호가 들어가있습니다
그래서 explode(',', $board['bo_notice']) 형식으로 배열의 정의하고
in_array 을 이용해서 게시판의 wr_id 의 정보가 있는 가를 확인하는거죠
예를 들면
$board_notice = array_map('trim', explode(',', $board['bo_notice']));
$is_notice = in_array($view['wr_id'], $board_notice);
<?php if($is_notice) { ?>
이런식으로 되게지요
그리고 혹시나해서 더쓰는데요 $is_notice 의 변수는 사용하지마세요
없는 기능을 만들때의 변수는 좀 특이 하게 만들어야 소스상 에러가 덜 나요
그리고 아래 분의 답변이 확실이 좋씁니다
lib/common.lib.php
// 게시물 정보($write_row)를 출력하기 위하여 $list로 가공된 정보를 복사 및 가공
function get_list($write_row, $board, $skin_url, $subject_len=40)
{
global $g5, $config;
global $qstr, $page;
//$t = get_microtime();
// 배열전체를 복사
$list = $write_row;
unset($write_row);
$board_notice = array_map('trim', explode(',', $board['bo_notice']));
$list['is_notice'] = in_array($list['wr_id'], $board_notice);
if ($subject_len)
$list['subject'] = conv_subject($list['wr_subject'], $subject_len, '…');
else
$list['subject'] = conv_subject($list['wr_subject'], $board['bo_subject_len'], '…');
// 목록에서 내용 미리보기 사용한 게시판만 내용을 변환함 (속도 향상) : kkal3(커피)님께서 알려주셨습니다.
if ($board['bo_use_list_content'])
{
$html = 0;
if (strstr($list['wr_option'], 'html1'))
$html = 1;
else if (strstr($list['wr_option'], 'html2'))
$html = 2;
$list['content'] = conv_content($list['wr_content'], $html);
}
$list['comment_cnt'] = '';
if ($list['wr_comment'])
$list['comment_cnt'] = "<span class=\"cnt_cmt\">".$list['wr_comment']."</span>";
// 당일인 경우 시간으로 표시함
$list['datetime'] = substr($list['wr_datetime'],0,10);
$list['datetime2'] = $list['wr_datetime'];
if ($list['datetime'] == G5_TIME_YMD)
$list['datetime2'] = substr($list['datetime2'],11,5);
else
$list['datetime2'] = substr($list['datetime2'],5,5);
// 4.1
$list['last'] = substr($list['wr_last'],0,10);
$list['last2'] = $list['wr_last'];
if ($list['last'] == G5_TIME_YMD)
$list['last2'] = substr($list['last2'],11,5);
else
$list['last2'] = substr($list['last2'],5,5);
$list['wr_homepage'] = get_text(addslashes($list['wr_homepage']));
$tmp_name = get_text(cut_str($list['wr_name'], $config['cf_cut_name'])); // 설정된 자리수 만큼만 이름 출력
if ($board['bo_use_sideview'])
$list['name'] = get_sideview($list['mb_id'], $tmp_name, $list['wr_email'], $list['wr_homepage']);
else
$list['name'] = '<span class="'.($list['mb_id']?'sv_member':'sv_guest').'">'.$tmp_name.'</span>';
$reply = $list['wr_reply'];
$list['reply'] = strlen($reply)*10;
$list['icon_reply'] = '';
if ($list['reply'])
$list['icon_reply'] = '<img src="'.$skin_url.'/img/icon_reply.gif" style="margin-left:'.$list['reply'].'px;" alt="답변글">';
$list['icon_link'] = '';
if ($list['wr_link1'] || $list['wr_link2'])
$list['icon_link'] = '<img src="'.$skin_url.'/img/icon_link.gif" alt="관련링크">';
// 분류명 링크
$list['ca_name_href'] = G5_BBS_URL.'/board.php?bo_table='.$board['bo_table'].'&sca='.urlencode($list['ca_name']);
$list['href'] = G5_BBS_URL.'/board.php?bo_table='.$board['bo_table'].'&wr_id='.$list['wr_id'].$qstr;
$list['comment_href'] = $list['href'];
$list['icon_new'] = '';
if ($board['bo_new'] && $list['wr_datetime'] >= date("Y-m-d H:i:s", G5_SERVER_TIME - ($board['bo_new'] * 3600)))
$list['icon_new'] = '<img src="'.$skin_url.'/img/icon_new.gif" alt="새글">';
$list['icon_hot'] = '';
if ($board['bo_hot'] && $list['wr_hit'] >= $board['bo_hot'])
$list['icon_hot'] = '<img src="'.$skin_url.'/img/icon_hot.gif" alt="인기글">';
$list['icon_secret'] = '';
if (strstr($list['wr_option'], 'secret'))
$list['icon_secret'] = '<img src="'.$skin_url.'/img/icon_secret.gif" alt="비밀글">';
// 링크
for ($i=1; $i<=G5_LINK_COUNT; $i++) {
$list['link'][$i] = set_http(get_text($list["wr_link{$i}"]));
$list['link_href'][$i] = G5_BBS_URL.'/link.php?bo_table='.$board['bo_table'].'&wr_id='.$list['wr_id'].'&no='.$i.$qstr;
$list['link_hit'][$i] = (int)$list["wr_link{$i}_hit"];
}
// 가변 파일
if ($board['bo_use_list_file'] || ($list['wr_file'] && $subject_len == 255) /* view 인 경우 */) {
$list['file'] = get_file($board['bo_table'], $list['wr_id']);
} else {
$list['file']['count'] = $list['wr_file'];
}
if ($list['file']['count'])
$list['icon_file'] = '<img src="'.$skin_url.'/img/icon_file.gif" alt="첨부파일">';
return $list;
}
// get_list 의 alias
function get_view($write_row, $board, $skin_url)
{
return get_list($write_row, $board, $skin_url, 255);
}
해결했습니다. 감사합니다..^^