상단 스킨 호출 문의 드립니다.

상단 스킨 호출 문의 드립니다.

QA

상단 스킨 호출 문의 드립니다.

본문

메인 페이지에서는 호출이 잘되는데...
게시판페이지 list, view, write 에서는 
500 (Internal Server Error)
에러가 발생하네요

그래서 각 페이지마다 

 

 

<?php

include_once(G5_THEME_PATH.'/blog_skin/Blog_top_1.php');

include_once(G5_THEME_PATH.'/blog_skin/Blog_top_2.php');

?>

 

이렇게 해서 추가해도 나타나지 않고...흠 제가 뭘 잘못햇을까요...


head.php


<main class="container">
<?php
include_once(G5_THEME_PATH.'/blog_skin/Blog_top_1.php');
include_once(G5_THEME_PATH.'/blog_skin/Blog_top_2.php');
?>
<div class="row">
    <div class="col-12 col-lg-8">   
 

 

tail.php


</div>
    <div class="col-12 col-lg-4">
        <div class="p-4 mb-3 bg-body-tertiary rounded">
        <h4 class="fst-italic">소개</h4>
        <p class="mb-0">내용입력</p>
        </div>
         <?php
          include_once(G5_THEME_PATH.'/blog_skin/Blog_Sidebar1.php');
          ?>
     </div>
</div>
</main>

Blog_top_1.php


<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
 
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
 
$boards = ['free', 'notice', 'qna'];
$posts_per_board = 5;
$desc_length = 80;
$thumb_width = 210;
$thumb_height = 150;
$background_size = 'cover';
$all_posts = [];
foreach ($boards as $board) {
    $sql = "SELECT *, '{$board}' as bo_table FROM {$g5['write_prefix']}{$board} ORDER BY wr_id DESC LIMIT $posts_per_board";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result)) {
        $all_posts[] = $row;
    }
}
 
usort($all_posts, function($a, $b) {
    return strtotime($b['wr_datetime']) - strtotime($a['wr_datetime']);
});
 
$latest_posts = array_slice($all_posts, 0, 5);
?>
 
<div class="container-fluid p-4 p-md-5 mb-4 rounded bg-body-secondary custom-bg">
    <div class="row">
        <?php foreach ($latest_posts as $post): ?>
        <?php
        preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $post['wr_content'], $matches);
        $img = !empty($matches[1]) ? $matches[1][0] : 'your-image-url-here.jpg';
        $title = strip_tags($post['wr_subject']);
        $content = cut_str(strip_tags($post['wr_content']), $desc_length);
        $link = G5_BBS_URL."/board.php?bo_table=".$post['bo_table']."&wr_id=".$post['wr_id'];
        ?>
        <div class="col-12 col-lg-6 px-0 d-none post" data-bg-image="<?php echo $img; ?>" style="background-size: <?php echo $background_size; ?>;">
            <div class="text-white p-4">
                <h1 class="h4 fst-italic title"><?php echo $title; ?></h1>
                <p class="lead my-3"><?php echo $content; ?></p>
                <a href="<?php echo $link; ?>" class="btn btn-secondary">더보기</a>
            </div>
        </div>
        <?php endforeach; ?>
    </div>
</div>
 
<style>
.custom-bg {
    background-size: <?php echo $background_size; ?>;
    background-position: center center;
    background-repeat: no-repeat;
}
 
.title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%
}
 
@media (max-width: 992px) {
    .custom-bg .row {
        flex-direction: column-reverse;
    }
    .custom-bg {
        padding-bottom: 100%;
    }
}
</style>
 
<script>
window.onload = function() {
    let currentPost = 0;
    const posts = document.querySelectorAll('.post');
    const customBg = document.querySelector('.custom-bg');
    const displayDuration = 15000;
 
    function showNextPost() {
        posts[currentPost].classList.add('d-none');
        currentPost = (currentPost + 1) % posts.length;
        const nextBgImageUrl = posts[currentPost].getAttribute('data-bg-image');
        customBg.style.backgroundImage = `linear-gradient(to right, rgba(255,255,255,0.7), transparent 50%), url('${nextBgImageUrl}')`;
        posts[currentPost].classList.remove('d-none');
    }
 
    if (posts.length > 0) {
        customBg.style.backgroundImage = `linear-gradient(to right, rgba(255,255,255,0.7), transparent 50%), url('${posts[0].getAttribute('data-bg-image')}')`;
        posts[0].classList.remove('d-none');
        setInterval(showNextPost, displayDuration);
    }
};
</script>
 

 

Blog_top_1.php


<?php
if (!defined('_GNUBOARD_')) exit;
include_once(G5_LIB_PATH.'/thumbnail.lib.php');
$board_sql = "SELECT bo_table, bo_subject FROM {$g5['board_table']}";
$board_result = sql_query($board_sql);
$board_names = [];
while ($board_row = sql_fetch_array($board_result)) {
    $board_names[$board_row['bo_table']] = $board_row['bo_subject'];
}
$boards = ['free', 'notice', 'qna'];
$posts_per_board = 5;
$desc_length = 40;
$thumb_width = 200;
$thumb_height = 250;
$all_posts = [];
foreach ($boards as $board) {
    $sql = "SELECT * FROM {$g5['write_prefix']}{$board} ORDER BY wr_id DESC LIMIT {$posts_per_board}";
    $result = sql_query($sql);
    while ($row = sql_fetch_array($result)) {
        preg_match_all("/<img[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i", $row['wr_content'], $matches);
        $img = !empty($matches[1]) ? $matches[1][0] : 'your-image-url-here.jpg';
        $full_title = strip_tags($row['wr_subject']);
        $title = $full_title;
        $content = cut_str(strip_tags($row['wr_content']), $desc_length);
        $content = html_entity_decode($content);
        $link = G5_BBS_URL."/board.php?bo_table={$board}&wr_id=".$row['wr_id'];
        $date = $row['wr_datetime'];
        $all_posts[] = [
            'board' => $board_names[$board],
            'img' => $img,
            'title' => $title,
            'content' => $content,
            'link' => $link,
            'date' => $date
        ];
    }
}
usort($all_posts, function($a, $b) {
    return strtotime($b['date']) - strtotime($a['date']);
});
$latest_posts = array_slice($all_posts, 0, $posts_per_board);
?>
 
<style>
.post-item img { transition: opacity 0.5s ease; }
.post-item img.fade-out { opacity: 0; visibility: hidden; }
 
.thumbnail-img {
    display: block;
    width: <?php echo $thumb_width; ?>px;
    height: <?php echo $thumb_height; ?>px;
    object-fit: cover;
    object-position: center;
}
</style>
 
<div class="row mb-2">
    <?php for ($i = 0; $i < 2; $i++): ?>
    <?php
        $post = $latest_posts[$i];
    ?>
    <div class="col-md-6 post-item">
        <div class="d-flex flex-nowrap g-0 border rounded overflow-hidden mb-4 shadow-sm h-md-250 position-relative">
            <div class="col p-4 d-flex flex-column position-static">
                <strong class="d-inline-block mb-2 text-primary"><?php echo $post['board']; ?></strong>
                <h4 class="mb-0 text-nowrap text-truncate"><?php echo htmlspecialchars($post['title']); ?></h4>
                <div class="mb-1 text-muted"><?php echo $post['date']; ?></div>
                <p class="card-text mb-auto"><?php echo $post['content']; ?></p>
                <a href="<?php echo $post['link']; ?>" class="stretched-link">더보기</a>
            </div>
            <div class="col-auto d-none d-lg-block overflow-hidden">
                <img class="thumbnail-img" src="<?php echo $post['img']; ?>" alt="Thumbnail" style="width: <?php echo $thumb_width; ?>px; height: <?php echo $thumb_height; ?>px;">
            </div>
        </div>
    </div>
    <?php endfor; ?>
</div>
 
<script>
document.addEventListener("DOMContentLoaded", function() {
    let currentPostIndex = 1;
    const posts = document.querySelectorAll('.post-item');
    const postData = <?php echo json_encode($latest_posts); ?>;
    const displayDuration = 15000;
 
    function showNextPost() {
        const leftPost = posts[0];
        const rightPost = posts[1];
        leftPost.innerHTML = rightPost.innerHTML;
        currentPostIndex = (currentPostIndex + 1) % postData.length;
        const nextPost = postData[currentPostIndex];
        const oldImage = rightPost.querySelector('.col-auto img');
        if (oldImage) {
            oldImage.classList.add('fade-out');
        }
        setTimeout(() => {
            if (oldImage) {
                oldImage.src = nextPost.img;
                oldImage.classList.remove('fade-out');
                oldImage.style.visibility = 'visible';
            }
        }, 500);
        const titleElement = rightPost.querySelector('h4.mb-0');
        const dateElement = rightPost.querySelector('.mb-1 text-muted');
        const contentElement = rightPost.querySelector('.card-text.mb-auto');
        const linkElement = rightPost.querySelector('a.stretched-link');
 
        if (titleElement) {
            titleElement.textContent = nextPost.title;
        }
        if (dateElement) {
            dateElement.textContent = nextPost.date;
        }
        if (contentElement) {
            contentElement.textContent = nextPost.content;
        }
        if (linkElement) {
            linkElement.href = nextPost.link;
        }
    }
    setInterval(showNextPost, displayDuration);
});
</script>

이 질문에 댓글 쓰기 :

답변 2

'{$board}'

이부분이 {$bo_table} 이렇게 들어가야 하지 않나 싶습니다

혹시 몰라서 남깁니다 위 스킨 사용시 

$boards = ['free', 'notice', 'qna'];
이 부분때문에 글작성이나 목록 이동시

마지막 qna 테이블로 모든 게시판이 연결되네요

그러니 혹시라도 위에 스킨은 사용하지 마시고 사용하실거면

https://sir.kr/g5_tip/4103 이페이지 최신글 호출 사용해서

스킨페이지 수정하시면 글작성, 목록 이동이 정상적으로 이동됩니다

혹시 모르고 사용하실까봐 댓글 남겨요
답변을 작성하시기 전에 로그인 해주세요.
전체 205
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT