게시글 날짜, 조회수 수정
게시판 글작성시 날짜 또는 조회수 변경하는 방법입니다. 다른분들거 참고하여 정리를 다시 하였습니다.
해당 게시글 스킨에서 다음과 같이 적용하시면 됩니다.
1. write.skin.php 코드추가
2. write_update.skin.php(파일생성)
1. write.skin.php 적당한 위치에 코드추가 (관리자만 수정할 수 있게금)
<?php if ($is_admin) { ?>
<!-- 관리자 권한 : 날짜 수정 시작 -->
<label class="col-sm-2 control-label" for="wr_subject">날짜수정<strong class="sound_only">자동(선택)</strong></label>
<div class="col-sm-10">
<div class="input-group">
<?php if ($is_admin && $w == "u") { ?>
<input class="form-control input-sm" maxlength="20" size="20" name="wr_datetime" itemname="날짜" required value="<?php echo $write['wr_datetime']?>">
<label>예) 2016-02-01 00:00:00 [양식 반드시 유지해야함. 에러주의]</label>
<?php } ?>
</div>
</div>
<label class="col-sm-2 control-label" for="wr_subject">조회수수정<strong class="sound_only">자동(선택)</strong></label>
<div class="col-sm-10">
<div class="input-group">
<?php if ($is_admin && $w == "u") { ?>
<input class="form-control input-sm" maxlength="20" size="20" name="wr_hit" itemname="조회수" required value="<?php echo $write['wr_hit']?>">
<label>예) 숫자만</label>
<?php } ?>
</div>
</div>
<!-- 관리자 권한 : 이름|날짜|조회 수정 끝 -->
<? } ?>
2. write_update.skin.php(파일생성) 후 아래에 같은 코드 적용
<?php
//쿼리문 실행
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
if($is_admin && $w != "c" && $w == "u"){
$sql = "update $write_table set wr_datetime='$wr_datetime',wr_hit='$wr_hit' where wr_id='$wr_id' ";
sql_query($sql);
}
?>
※ 다온스타일
<?php if ($is_admin && $w == 'u') { ?>
<!-- 관리자 권한 : 날짜 및 조회수 수정 시작 -->
<div class="bo_w_tit write_div">
<label for="set_now_datetime" class="sound_only">현재날짜적용</label>
<input type="checkbox" id="set_now_datetime" style="margin-bottom:10px;">
<label for="set_now_datetime">현재 날짜와 시간 입력</label>
<div class="bo_w_tit write_div">
<label for="wr_datetime" class="sound_only">날짜수정<strong>필수</strong></label>
<input type="text" name="wr_datetime" value="<?php echo $write['wr_datetime']?>" id="wr_datetime" required class="frm_input full_input required" size="50" maxlength="20" placeholder="예) 2016-02-01 00:00:00 [양식 유지 필수]">
</div>
<div class="bo_w_tit write_div">
<label for="wr_hit" class="sound_only">조회수수정<strong>필수</strong></label>
<input type="text" name="wr_hit" value="<?php echo $write['wr_hit']?>" id="wr_hit" required class="frm_input full_input required" size="50" maxlength="20" placeholder="숫자만 입력">
</div>
<!-- 관리자 권한 : 날짜 및 조회수 수정 끝 -->
<script>
document.getElementById('set_now_datetime').addEventListener('change', function() {
if (this.checked) {
var now = new Date();
var year = now.getFullYear();
var month = ('0' + (now.getMonth() + 1)).slice(-2);
var day = ('0' + now.getDate()).slice(-2);
var hours = ('0' + now.getHours()).slice(-2);
var minutes = ('0' + now.getMinutes()).slice(-2);
var seconds = ('0' + now.getSeconds()).slice(-2);
var formatted = year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
document.getElementById('wr_datetime').value = formatted;
}
});
</script>
<?php } ?>
댓글 2개
게시글 목록
| 번호 | 제목 |
|---|---|
| 24318 | |
| 24317 | |
| 24315 | |
| 24309 | |
| 24294 | |
| 24293 | |
| 24277 | |
| 24262 | |
| 24260 | |
| 24253 | |
| 24251 | |
| 24236 | |
| 24233 | |
| 24228 | |
| 24226 | |
| 24221 | |
| 24214 | |
| 24203 | |
| 24201 | |
| 24199 | |
| 24196 | |
| 24195 | |
| 24194 | |
| 24192 | |
| 24191 | |
| 24187 | |
| 24185 | |
| 24183 | |
| 24172 | |
| 24168 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기