이벤트 게시판 만들기 > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

이벤트 게시판 만들기 정보

이벤트 게시판 만들기

본문

이벤트 게시판 만들기
list.php
========================================================================================================
1. 상단에 이미지 사이즈를 정해준다
$banner_img_width = '320'; // 배너이미지 넓이
$banner_img_height = '80'; // 배너이미지 높이

2. 현재 시간을 추출한다
$current_time = time(); // 날짜 계산을 위한 현재시간 추출

3. 내용이 출력되는 부분에 아이콘 및 게시물을 출력한다
<table cellspacing="0" cellpadding="0" class="board_list">
    <? if ($is_checkbox) { ?><col width="30" /><? } ?>
    <col width="<?=$banner_img_width + 10?> " />
    <col  />
    <?
    for ($i=0; $i<count($list); $i++) {
        $bg = $i%2 ? 0 : 1;
    ?>
    <? if ($i != 0) { ?><tr><td colspan='2' height="15" style="border-top:0px; border-bottom:0px;"></td></tr><? } // 게시물 사이 넓이 ?>
    <tr class="bg0" >
      <? if ($is_checkbox) { ?><td class="checkbox"><input type=checkbox name=chk_wr_id[] value="<?=$list[$i][wr_id]?>"></td><? } ?>

<?
$wr_1 = strtotime($list[$i][wr_1]) + ($list[$i][wr_2] * 3600); // 시작날짜 + 시작시간 계산
$wr_3 = strtotime($list[$i][wr_3]) + ($list[$i][wr_4] * 3600); // 마감날짜 + 마감시간 계산

$wr_1_text = date("Y년 m월 d일", $wr_1);
$wr_3_text = date("Y년 m월 d일", $wr_3);

if($wr_1 < $current_time && $wr_3 > $current_time){ // 진행중 아이콘
$ico_state_img = "ico_state.gif";
}else if($wr_3 < $current_time){ // 완료 아이콘
$ico_state_img = "ico_state_complete.gif";
}else if($wr_1 > $current_time){ // 진행전 아이콘
$ico_state_img = "ico_state_before.gif";
}
?>
<td class="subject">
        <div class="event_list_img">
<?
if($list[$i][file][0][view]) {
$src = $list[$i][file][0][path]."/".$list[$i][file][0][file];
echo ("<a href='{$list[$i][href]}'><img src='$src' width='{$banner_img_width}' height='{$banner_img_height}'></a>");
}
?>
</div>
</td>
<td class="subject">
<div class="event_list_text">
<ul>
          <?
            echo $nobr_begin;
            echo "<li>제목 : <a href='{$list[$i][href]}'>{$list[$i][subject]}</a> ". $list[$i][icon_new] . "</li>";
echo "<li>기간 : $wr_1_text ~ $wr_3_text</li>";
echo "<li>진행상태 : <img src='{$board_skin_path}/img/{$ico_state_img}'></li>";
echo "<li><a href='{$list[$i][href]}'><img src='{$board_skin_path}/img/btn_event_view.gif'></a></li>";
            echo $nobr_end;
          ?>
      </ul>
        </div>
</td>
</tr>

    <? } // end for ?>

    <? if (count($list) == 0) { echo "<tr><td colspan='$colspan' height=100 align=center>등록된 이벤트가 없습니다.</td></tr>"; } ?>

    </table>


write.php
========================================================================================================
1. 상단에 시작시간과 마감시간을 추출하기 위한 함수를 넣는다
// 시작시간과 마감시간을 추출하기 위한 함수
function get_time_select($name, $start_id=0, $end_id=23, $selected='', $event='')
{
    global $g4;

    $str = "<select name='$name' $event>";
    for ($i=$start_id; $i<=$end_id; $i++)
    {
        $str .= "<option value='$i'";
        if ($i == $selected)
            $str .= " selected";
        $str .= ">$i</option>";
    }
    $str .= "</select>";
    return $str;
}

2. 이벤트 기간을 설정하는 항목을 추가한다
<tr>
                    <td class="write_head">이벤트 기간</td>
                    <td>시작날짜 <input class='ed' type=text id=wr_1 name='wr_1' size=8 maxlength=8 minlength=8 required numeric itemname='시작날짜' value='<?=$write[wr_1]?>' readonly title='옆의 달력 아이콘을 클릭하여 날짜를 입력하세요.'>
                              <a href="javascript:win_calendar('wr_1', document.getElementById('wr_1').value, '');"><img src='<?=$board_skin_path?>/img/calendar.gif' border=0 align=absmiddle title='달력 - 날짜를 선택하세요'></a>
                              시작시간 <? echo get_time_select("wr_2", 0, 23, $write[wr_2]) ?> 시
                            ~
                                마감날짜 <input class='ed' type=text id=wr_3 name='wr_3' size=8 maxlength=8 minlength=8 required numeric itemname='마감날짜' value='<?=$write[wr_3]?>' readonly title='옆의 달력 아이콘을 클릭하여 날짜를 입력하세요.'>
                              <a href="javascript:win_calendar('wr_3', document.getElementById('wr_3').value, '');"><img src='<?=$board_skin_path?>/img/calendar.gif' border=0 align=absmiddle title='달력 - 날짜를 선택하세요'></a> 
                              마감시간 <? echo get_time_select("wr_4", 0, 23, $write[wr_4]) ?> 시
                    </td></tr>
                <tr><td colspan="2" class='write_line'></td></tr>

추천
2

댓글 0개

전체 3,313 |RSS
그누4 팁자료실 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT