게시물의 성격에 따라 마감일자가 있는 게시물이 있습니다. 예를 들면 각종 이벤트나 쿠폰 정보같은 게시물입니다.

 

이와 같은 게시물의 경우 게시물 작성 시 확장변수에 마감일을 기재한 후 현재일자와 비교해서 제목에 자동으로 현재 게시물의 상태( 종료, 오늘종료, 진행중 등등 )를 변경 해 주고 싶은 경우 사용할 만한 팁입니다.

 

에덴게시판 스킨기준 입니다. 

 

[ table.html ] 목록 제목이 표시되는 위치쯤에 아래 코드를 넣어주세요.

코드 중 {@ $date = $document->getExtraEidValue('end')}

// 'end'는 게시판에 설정한 확장변수명을 기입 해 주세요.

   

    <td class="title" cond="$val->type=='title' && $val->idx==-1">
          <a href="{getUrl('document_srl',$document->document_srl, 'listStyle', $listStyle, 'cpage','')}" class="ed link-reset" style="<!--@if($module_info->list_table_row_height)-->padding-top: {$module_info->list_table_row_height}; padding-bottom: {$module_info->list_table_row_height}<!--@end-->">
            <strong class="ed margin-right-xsmall" cond="$document->get('category_srl')" style="color:{$category_list[$document->get('category_srl')]->color}"|cond="$category_list[$document->get('category_srl')]->color!='transparent'">[{$category_list[$document->get('category_srl')]->title}]</strong>
           
           {@ $now = date("Ymd");}]

{@ $date = $document->getExtraEidValue('end')}

<!--@if(!$date)-->
<span class="ed title-link">{$document->getTitle($module_info->list_title_limit)}</span>
<!--@elseif($now > $date)-->
<span class="ed title-link" style="color:#a6a6a6;text-decoration: line-through  !important;">[종료] {$document->getTitle($module_info->list_title_limit)}</span>
<!--@elseif($now < $date)-->
<span class="ed title-link">[진행중] {$document->getTitle($module_info->list_title_limit)}</span>
<!--@elseif($now == $date)-->
<span class="ed title-link">[오늘종료] {$document->getTitle($module_info->list_title_limit)}</span>
<!--@end-->

            
            <span class="ed text-primary" cond="$document->getCommentCount()">{$document->getCommentCount()}</span>

 

[ 결과 ]

 

입력한 게시물의 마감일 확장변수에 입력된 값이 오늘과 같을 때 : [ 오늘종료 ]  제목으로 출력

입력한 게시물의 마감일 확장변수에 입력된 값이 오늘 보다 이전날자일 때  : [ 종료 ]  제목으로 출력

입력한 게시물의 마감일 확장변수에 입력된 값이 오늘 보다 이후 날자일 때  : [ 진행중 ]  제목으로 출력

입력한 게시물의 마감일 확장변수에 입력된 값이 없을 때  : 제목으로 출력

 

* 오늘날자는 12월3일이고 종료일을 비교한 결과입니다.

111.BMP.jpg

 

 

2019-12-03 18,34,33.JPG

  • profile
    {@ $now = date("Ymd");}] 에서 ] 삭제해주시고, <span class="ed title-link">{$document->getTitle($module_info->list_title_limit)}</span> 이 부분을 대체 또는 주석처리하면 적용됩니다^^ 좋은 팁 감사합니다.
  • profile ?
    오타가 있었네요. ^^;
  • ?
    좋은 팁 감사합니다.^.^
  • ?
    [ 본문에 오타가 있습니다. 사용하실 분들은 아래 소스로 수정해 주세요.]

    {@ $now = date("Ymd");}
    {@ $date = $document->getExtraEidValue('end')}

    <!--@if(!$date)-->
    <span class="ed title-link">{$document->getTitle($module_info->list_title_limit)}</span>
    <!--@elseif($now > $date)-->
    <span class="ed title-link" style="color:#a6a6a6;text-decoration: line-through !important;">[종료] {$document->getTitle($module_info->list_title_limit)}</span>
    <!--@elseif($now < $date)-->
    <span class="ed title-link">[진행중] {$document->getTitle($module_info->list_title_limit)}</span>
    <!--@elseif($now == $date)-->
    <span class="ed title-link">[오늘종료] {$document->getTitle($module_info->list_title_limit)}</span>
    <!--@end-->