그누보드 [G5] 최근글 추출하기
페이지 정보
본문
최근 30일간에 올라온 게시글을 추출해서 보여줍니다
기간은 환경설정의 "최근게시글 삭제"의 일수를 변경하면 오랜 기간 누적된 최근게시글을 볼 수 있습니다.
<div class="latestBox scrollObj" data-scroll="top" data-delay="100">
<div class="tit">
<h3>공지사항</h3>
<a href="#" class="more">+ MORE</a>
</div>
<?php echo latest('theme/withcom_lastest', "notice", 5, 25); ?>
</div>
<div class="latestBox scrollObj" data-scroll="top" data-delay="300">
<?php /*<div class="tit">
<h3>교육홍보자료</h3>
<a href="#" class="more">+ MORE</a>
</div>
<?php echo latest('theme/withcom_lastest', "dataroom2", 5, 25); ?>
<?php */ ?>
<div class="tit">
<h3>최근 게시글</h3>
<a href="<?php echo G5_BBS_URL; ?>/new.php" class="more">+ MORE</a>
</div>
<?php
$new_count = 5;
$cnt = 0;
$sql = " select a.bo_table, a.wr_parent, b.bo_subject from {$g5['board_new_table']} a
left join {$g5['board_table']} b on (a.bo_table = b.bo_table)
where a.wr_id = a.wr_parent
group by a.bo_table, a.wr_parent
order by a.bn_id desc
limit {$new_count}
";
$res = sql_query($sql);
?>
<style>
.lnew {margin-top:0px; border:0px solid #ddd; padding:0px;}
.lnew ul {padding:0px 0;}
.lnew li {position:relative;border-bottom:0px solid #e5ecee;margin-bottom:0px;}
.lnew li a {line-height:28px;font-weight:normal;vertical-align:middle}
.lnew li a:hover {color:#3a8afd}
.lnew_date {font-size:1em;color:#636363;}
</style>
<div class="lnew">
<ul>
<?php
for ($i=0; $row=sql_fetch_array($res), $i<$new_count; $i++)
{
if (!$row['bo_table'])
{
continue;
}
$sql2 = " select wr_subject, wr_comment, wr_datetime from {$g5['write_prefix']}{$row['bo_table']} where wr_id = '{$row['wr_parent']}' ";
$row2 = sql_fetch($sql2);
$subj = cut_str(get_text($row2['wr_subject']), 15);
$comment = "";
if ($row2['wr_comment'])
$comment = "<span class=new>* {$row2['wr_comment']}</span>";
?>
<li class="lnew_subject">
<div style="float:left;">
<a href="<?php echo G5_BBS_URL; ?>/board.php?bo_table=<?php echo $row['bo_table']; ?>&wr_id=<?php echo $row['wr_parent']; ?>">[<?php echo $row['bo_subject']; ?>] <?php echo $subj; ?> <?php echo $comment; ?></a>
</div>
<div style="float:right;">
<span class="lnew_date"><?php echo substr($row2['wr_datetime'],0,10); ?></span>
</div>
<div style="clear:both;"></div>
</li>
<?php
$cnt++;
}
if (!$cnt) echo "<li style='height:100px; text-align:center;'>최근 {$config['cf_new_del']}일 이내 작성된 게시글이 없습니다.</li>";
?>
</ul>
</div>
</div>
참고자료
https://sir.kr/g5_tip/1322
기간은 환경설정의 "최근게시글 삭제"의 일수를 변경하면 오랜 기간 누적된 최근게시글을 볼 수 있습니다.
<div class="latestBox scrollObj" data-scroll="top" data-delay="100">
<div class="tit">
<h3>공지사항</h3>
<a href="#" class="more">+ MORE</a>
</div>
<?php echo latest('theme/withcom_lastest', "notice", 5, 25); ?>
</div>
<div class="latestBox scrollObj" data-scroll="top" data-delay="300">
<?php /*<div class="tit">
<h3>교육홍보자료</h3>
<a href="#" class="more">+ MORE</a>
</div>
<?php echo latest('theme/withcom_lastest', "dataroom2", 5, 25); ?>
<?php */ ?>
<div class="tit">
<h3>최근 게시글</h3>
<a href="<?php echo G5_BBS_URL; ?>/new.php" class="more">+ MORE</a>
</div>
<?php
$new_count = 5;
$cnt = 0;
$sql = " select a.bo_table, a.wr_parent, b.bo_subject from {$g5['board_new_table']} a
left join {$g5['board_table']} b on (a.bo_table = b.bo_table)
where a.wr_id = a.wr_parent
group by a.bo_table, a.wr_parent
order by a.bn_id desc
limit {$new_count}
";
$res = sql_query($sql);
?>
<style>
.lnew {margin-top:0px; border:0px solid #ddd; padding:0px;}
.lnew ul {padding:0px 0;}
.lnew li {position:relative;border-bottom:0px solid #e5ecee;margin-bottom:0px;}
.lnew li a {line-height:28px;font-weight:normal;vertical-align:middle}
.lnew li a:hover {color:#3a8afd}
.lnew_date {font-size:1em;color:#636363;}
</style>
<div class="lnew">
<ul>
<?php
for ($i=0; $row=sql_fetch_array($res), $i<$new_count; $i++)
{
if (!$row['bo_table'])
{
continue;
}
$sql2 = " select wr_subject, wr_comment, wr_datetime from {$g5['write_prefix']}{$row['bo_table']} where wr_id = '{$row['wr_parent']}' ";
$row2 = sql_fetch($sql2);
$subj = cut_str(get_text($row2['wr_subject']), 15);
$comment = "";
if ($row2['wr_comment'])
$comment = "<span class=new>* {$row2['wr_comment']}</span>";
?>
<li class="lnew_subject">
<div style="float:left;">
<a href="<?php echo G5_BBS_URL; ?>/board.php?bo_table=<?php echo $row['bo_table']; ?>&wr_id=<?php echo $row['wr_parent']; ?>">[<?php echo $row['bo_subject']; ?>] <?php echo $subj; ?> <?php echo $comment; ?></a>
</div>
<div style="float:right;">
<span class="lnew_date"><?php echo substr($row2['wr_datetime'],0,10); ?></span>
</div>
<div style="clear:both;"></div>
</li>
<?php
$cnt++;
}
if (!$cnt) echo "<li style='height:100px; text-align:center;'>최근 {$config['cf_new_del']}일 이내 작성된 게시글이 없습니다.</li>";
?>
</ul>
</div>
</div>
참고자료
https://sir.kr/g5_tip/1322
댓글목록
등록된 댓글이 없습니다.