https://www.070805.com/blog/48453 << 출처

 

다음 코드를 module_srl번호에 따라서 n 표현을 하고싶습니다.

현재 180 ,174 번에 새글이 올라오면 시간을 1500초(테스트를위해서..)이내에 글은 n으로 표현되어있습니다.

 

{@ 
    $args = new stdClass();
    $args->module_srl = '180','174';
    $args->list_count = 1;
    $output = executeQuery('document.getDocumentList', $args);
}                        
<!--@foreach($output->data as $doc)-->
    {@ $regdate = strtotime($doc->regdate);}
<!--@end-->                        
{@ 
    if(!$output->data) unset($regdate);
    $newdoc = false;
    $yesterdaytime = time() - 1500;
    if($regdate > $yesterdaytime) $newdoc = true;
}
<span cond="$newdoc" class="new" style="position:relative;top:50px;left:200px;">N</span>
{@    
    unset($newdoc);
}

 

이런 코드를 다음과 같이 둘로 나누어서 사용하려고합니다. 

{@ 
    $args = new stdClass();
    $args->module_srl = '180';
    $args->list_count = 1;
    $output = executeQuery('document.getDocumentList', $args);
}                        
<!--@foreach($output->data as $doc)-->
    {@ $regdate = strtotime($doc->regdate);}
<!--@end-->                        
{@ 
    if(!$output->data) unset($regdate);
    $newdoc = false;
    $yesterdaytime = time() - 1500;
    if($regdate > $yesterdaytime) $newdoc = true;
}
<span cond="$newdoc" class="new" style="position:relative;top:50px;left:200px;">N</span>
{@
        unset($newdoc);
}

 

{@ 
    $args = new stdClass();
    $args->module_srl = '174';
    $args->list_count = 1;
    $output = executeQuery('document.getDocumentList', $args);
}                        
<!--@foreach($output->data as $doc)-->
    {@ $regdate = strtotime($doc->regdate);}
<!--@end-->                        
{@ 
    if(!$output->data) unset($regdate);
    $newdoc = false;
    $yesterdaytime = time() - 1500;
    if($regdate > $yesterdaytime) $newdoc = true;
}
<span cond="$newdoc" class="new" style="position:relative;top:250px;left:200px;">N</span>
{@
       unset($newdoc);
}

 

이런식으로 둘로 나눠서 사용하려고 합니다.

다만 게시판이 많아질수록 코드또한 길어지게되어서 해당내용을 반복문으로 변경하여 module_srl 번호에따라 span 내용을 변경하고싶습니다.  코드 수정좀 부탁드리겟습니다 

  • ?
    if($module_info->module_srl==174||$module_info->module_srl==180){
    출력
    }

    요런식으로 하면 되지 않을까 싶은ㄷ
  • profile

    아마 게시판 새글알림을 만드시려는 것 같네요.

    function으로 만들면 됩니다.

    대강 이런 식이죠.

     

    <?
    function new_chk($m_srl) {
    {@ 
    $args = new stdClass();
    $args->module_srl = $m_srl;//모듈srl만 변수로 입력 받음
    $args->list_count = 1;
    $output = executeQuery('document.getDocumentList', $args);
    }
    <!--@foreach($output->data as $doc)-->
    {@ $regdate = strtotime($doc->regdate);}
    <!--@end-->
    {@
    if(!$output->data) unset($regdate);
    $newdoc = false;
    $yesterdaytime = time() - 1500;
    if($regdate > $yesterdaytime) $newdoc = true;
    }
    <span cond="$newdoc" class="new" style="position:relative;top:250px;left:200px;">N</span>
    {@
    unset($newdoc);
    }
    }
    ?>
    
    html내용이 어쩌고 저쩌고 요기에 <? new_chk("184"); ?>
    
    
    html내용이 어쩌고 저쩌고 요기에 <? new_chk("179"); ?>
    
    
    html내용이 어쩌고 저쩌고 요기에 <? new_chk("250"); ?>

     

  • profile profile
    <? new_chk("250"); ?> 250에 해당되는게 게시판 번호인건가요?
  • profile profile
    죄송해여 이해를 못해서 그대로 복붙햇는데 에러가납니다 ㅜㅜ...
  • profile profile
    모듈srl이니 게시판의 고유번호라고 할 수 있죠.
  • profile profile
    어디에 붙여넣으셨나요?
  • profile profile
    게시판 스킨에 붙여넣기했습니다.. 어찌할지몰라서 걍 19줄이길래 쭉늘릴예정이였어요 ..ㅋㅋ;;
  • profile profile
    <? function new_chk($m_srl) { ?>
    {@
    $args = new stdClass();
    $args->module_srl = $m_srl;//모듈srl만 변수로 입력 받음
    $args->list_count = 1;
    $output = executeQuery('document.getDocumentList', $args);
    }
    <!--@foreach($output->data as $doc)-->
    {@ $regdate = strtotime($doc->regdate);}
    <!--@end-->
    {@
    if(!$output->data) unset($regdate);
    $newdoc = false;
    $yesterdaytime = time() - 1500;
    if($regdate > $yesterdaytime) $newdoc = true;
    }
    <span cond="$newdoc" class="new" style="position:relative;top:250px;left:200px;">N</span>
    {@
    unset($newdoc);
    }
    <? } ?>

     

  • profile profile

    function부분을 위처럼 넣어보세요.

  • profile profile
    헛 감사합니다 에러없이 떴습니다 오..
  • profile profile
    <? new_chk("180"); ?>
    <? new_chk("174"); ?>
    둘중 하나만 성립되도 N표기가 되어버립니다 ㅜ..
  • profile profile
    두개를 연달아서 쓰면
    당연히 둘다 없으면 아무것도 없을테고, 1개면 N, 2개면 NN이 나올텐데요.
  • profile profile
    관련없는 게시판에 글을써도 n 표기가 됩니다
  • profile
    <? new_chk(); ?>으로도 n표기가 됩니다 $m_srl 값에따라서 설정하는게 안되는거 같아요
  • profile profile
    function으로 감싼 부분이 function이 되지 않고 코드 자체로 동작하는게 아닌가 싶습니다.