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 내용을 변경하고싶습니다. 코드 수정좀 부탁드리겟습니다
댓글 15
출력
}
요런식으로 하면 되지 않을까 싶은ㄷ
아마 게시판 새글알림을 만드시려는 것 같네요.
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"); ?>
{@
$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);
}
<? } ?>
function부분을 위처럼 넣어보세요.
<? new_chk("174"); ?>
둘중 하나만 성립되도 N표기가 되어버립니다 ㅜ..
당연히 둘다 없으면 아무것도 없을테고, 1개면 N, 2개면 NN이 나올텐데요.