답변 4개
게시판 게시글 테이블에 똑같이 저장 됩니다.
wr_is_comment 값이 1이면 코멘트 0이면 게시글입니다.
![]()
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
마르스 컴퍼니님 고견 감사합니다~~
로그인하면 이리 저리 글읽다가 그동안 로그인한 회원이 쓴 글을 동태를 알 수 있지 않을까 해서 필요하지 않을까 해서 view 페이지에 넣으려고 했습니다 님의 의견을 읽고나니 마이페이지 등에 넣어야 할듯합니다
댓글을 작성하려면 로그인이 필요합니다.
마르스컴퍼니님 제가 올린것도 좀 봐주세요~~ 로그인한 회원의 최근게시글과 댓글 뽑는 건데 view.skin.php 에 넣어서 출력하려고 했지만 게시판이 아닌 곳에서는 정상 출력되는데 view.skin.php 에서는 최신글과 댓글은 출력되는데 페이지에 오류가 생겨요
답변에 대한 댓글 1개
로그인 유저의 최근글/댓글을 보여주는 것인지 명확히 해야 합니다.
view.skin.php 는 글 뷰 페이지입니다.
글 뷰페이지에서 (글을 읽고 있는) '로그인 유저'의 최근글/댓글을 보여주는 것은 이상해 보입니다.
글 작성자의 최근글/댓글을 보여주는 것이 자연스러워 보입니다.
* 글 작성자의 최근 게시글 및 댓글
[code]
<?php
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
$author_id = $view['mb_id'];
// 최근 게시글 조회 (원글만)
$recent_posts_query = "
SELECT *
FROM {$g5['board_new_table']}
WHERE mb_id = '$author_id'
AND wr_id = wr_parent
ORDER BY bn_datetime DESC
LIMIT 10
";
$recent_posts_result = sql_query($recent_posts_query);
// 최근 댓글 조회
$recent_comments_query = "
SELECT *
FROM {$g5['board_new_table']}
WHERE mb_id = '$author_id'
AND wr_id <> wr_parent
ORDER BY bn_datetime DESC
LIMIT 10
";
$recent_comments_result = sql_query($recent_comments_query);
?>
<!-- 게시글 출력 -->
<div id="lt_side">
<fieldset id="recent_posts">
<legend>작성자의 최근 게시글</legend>
<div class="fw-bold fs-5">작성자의 최근 게시글</div>
<ul>
<?php if (sql_num_rows($recent_posts_result) == 0): ?>
<li>최근 게시글이 없습니다.</li>
<?php else: ?>
<?php for ($i = 1; $row = sql_fetch_array($recent_posts_result); $i++):
$post_url = get_pretty_url($row['bo_table'], $row['wr_id']);
$post_info = sql_fetch(" SELECT wr_subject FROM {$g5['write_prefix']}{$row['bo_table']} WHERE wr_id = '{$row['wr_id']}' ");
$post_title = $post_info['wr_subject'];
if (mb_strlen($post_title) > 50) {
$post_title = mb_substr($post_title, 0, 50) . '...';
}
?>
<li><?php echo $i; ?>. <a href="<?php echo $post_url; ?>"><?php echo htmlspecialchars($post_title); ?></a> - <?php echo $row['bn_datetime']; ?></li>
<?php endfor; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
<!-- 댓글 출력 -->
<div id="lt_side">
<fieldset id="recent_comments">
<legend>작성자의 최근 댓글</legend>
<div class="fw-bold fs-5">작성자의 최근 댓글</div>
<ul>
<?php if (sql_num_rows($recent_comments_result) == 0): ?>
<li>최근 댓글이 없습니다.</li>
<?php else: ?>
<?php for ($i = 1; $row = sql_fetch_array($recent_comments_result); $i++):
$post_url = get_pretty_url($row['bo_table'], $row['wr_parent']);
$comment_info = sql_fetch(" SELECT wr_content FROM {$g5['write_prefix']}{$row['bo_table']} WHERE wr_id = '{$row['wr_id']}' ");
$comment_content = $comment_info['wr_content'];
if (mb_strlen($comment_content) > 30) {
$comment_content = mb_substr($comment_content, 0, 30) . '...';
}
?>
<li><?php echo $i; ?>. <a href="<?php echo $post_url; ?>"><?php echo htmlspecialchars($comment_content); ?></a> - <?php echo $row['bn_datetime']; ?></li>
<?php endfor; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
[/code]
댓글을 작성하려면 로그인이 필요합니다.
그누보드5에서는 댓글이 g5_write_[게시판명] 테이블에 저장됩니다. 여기서 '게시판명'은 실제 게시판의 테이블명입니다.
그누보드5에서 로그인한 회원의 전체 게시판 댓글을 추출하여 리스트로 출력하는 샘플 코드
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인