흩어져있는 각각의 게시판을 한개의 최신글에서 불러오고 싶어요 > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

흩어져있는 각각의 게시판을 한개의 최신글에서 불러오고 싶어요 정보

흩어져있는 각각의 게시판을 한개의 최신글에서 불러오고 싶어요

본문

말 그대로

메인화면 최신글(latest) 한 곳에 여기저기 흩어져있는 게시판을 모아오고 싶습니다.

즉, "가"그룹 밑에 "가_1" "가_2" "가_3" "가_4"라는 게시판들이 있고
    "나"그룹 밑에 "나_1" "나_2" "나_3" "나_4"라는 게시판들이 있고
    "다"그룹 밑에 "다_1" "다_2" "다_3" "다_4"라는 게시판들이 있다고 했을때

최신글에서는 그룹에 상관없이 가령 "가_1" "가_2" "나_2" "나_4" "다_1" ... 이런식으로 (순서상관없이 최근작성된 글순서대로) 뽑아보려고 합니다.

질문답변, 팁 여기저기 뒤져봐도 보통 하나의 '그룹'에서 특정한 게시판을 제외하거나 하는 것은 봤었거든요..

어떻게 해야하나요.. 게시판 전체리스트를 출력하고 거기서 예외규정을 두는방식인가요?

도와주세요.. 부탁드립니다. ..
  • 복사

댓글 전체

http://sir.co.kr/bbs/board.php?bo_table=g4_skin&wr_id=62547&sca=&sfl=wr_subject&stx=%B3%AA%C0%C7+%C3%D6%BD%C5&sop=and

여기 보면 그룹 최신 글이 있습니다.

앞 부분을 이렇게 바꿔 보세요.

function latest_group( $skin_dir, $bo_tables, $rows=10, $subject_len="", $content_len="") {
    global $g4;

    if ($skin_dir) $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $rows2 = $rows * 2; // 비밀글을 제외할 때 rows가 부족할까봐 여유있게
    array_walk( $bo_tables , 'quoting');
    $bo_tables= implode( ',', $bo_tables);

    $sql = " select bo_table, wr_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";
    $result = sql_query($sql);
엑스엠엘님 답변 감사드립니다.

그런데 이런 에러가 뜹니다.. 어디서 문제인지요..

Warning: array_walk(): Unable to call quoting() - function does not exist in /home/sustain.kr/public_html/html/lib/latest.group.lib.php on line 14

select bo_table, wr_id from g4_board_new where bo_table in ( notice_6,full,goodco ) and wr_is_comment=0 order by bn_id desc limit 0, 6

1054 : Unknown column 'notice_6' in 'where clause'

error file : /index4.php


=============================================

index4의 해당 적용부분은 엑스엠엘님이 가르쳐주신대로  아래와 같이 했구요.
앞부분에는 include_once("$g4[path]/lib/latest.group.lib.php"); 를 해두었습니다.


<td width="465" height="137" align="center"  valign="top"><?php echo latest_group("latest_box_bird", array( 'notice_6', 'full', 'goodco'), 3, 27); ?>

==================================================

lib/latest.group.lib.php 이 부분은 아래와 같이 앞부분만 수정했구요...

<?
if (!defined('_GNUBOARD_')) exit;

// 최신글 추출
function latest_group( $skin_dir, $bo_tables, $rows=10, $subject_len="", $content_len="") {
    global $g4;

    if ($skin_dir) $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $rows2 = $rows * 2; // 비밀글을 제외할 때 rows가 부족할까봐 여유있게
    array_walk( $bo_tables , 'quoting');
    $bo_tables= implode( ',', $bo_tables);

    $sql = " select bo_table, wr_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";
    $result = sql_query($sql);


    $j = 0;
    while ($row = sql_fetch_array($result)) {
     
        if ($j > $rows) break; // rows에 지정된거보다 많으면 loop를 중단. 비밀글이 많으면 rows보다 적은 열이 return됨 (그대로 효율이 중요하죠)
       
      // 게시판 테이블
        $sql3 = " select * from $g4[board_table] where bo_table = '$row[bo_table]'";
        $board = sql_fetch($sql3);

        $tmp_write_table = $g4[write_prefix] . $row[bo_table];
        $sql2 = " select * from $tmp_write_table where wr_id = '$row[wr_id]' ";
        $row2 = sql_fetch($sql2);
       
        if (!strstr($row2[wr_option], "secret")) {
            $list[$j] = get_list($row2, $board, $latest_skin_path, $subject_len);
            $list[$j][bo_name] = $board[bo_subject];
            $j++;
        }
    }
   
    $result4 = sql_fetch(" select gr_subject from $g4[group_table] where gr_id = '$gr_id' ");
    $skin_title = "$result4[gr_subject]";
    $skin_title_link = "?url=$g4[bbs_path]/new.php?gr_id=$gr_id";
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
다음을 보시고 quoting 함수 추가해 주세요.

<?php
if (!defined('_GNUBOARD_')) exit;

function quoting(&$item1, $key) { $item1 = "'$item1'"; }
// 최신글 추출
function latest_group( $skin_dir, $bo_tables, $rows=10, $subject_len="", $content_len="") {
엑스엠엘님 지적대로  lib/latest.group.lib.php  앞부분에 위의 문구를 대체시키고 돌렸습니다.

이번엔 이런 에러가...

select bo_table, wr_id from g4_board_new where bo_table in ( 'notice_6','full','goodco' ) and wr_is_comment=0 order by bn_id desc limit 0, 6

1054 : Unknown column 'wr_is_comment' in 'where clause'

error file : /index4.php

***************************************************
**참고로 현재 latest.group.lib.php  소스는 이렇습니다.. 엑스엠엘님 신경써주셔서 진심으로 감사드립니다. ^^


<?php
if (!defined('_GNUBOARD_')) exit;

function quoting(&$item1, $key) { $item1 = "'$item1'"; }
// 최신글 추출
function latest_group( $skin_dir, $bo_tables, $rows=10, $subject_len="", $content_len="") {
 
    global $g4;

    if ($skin_dir) $latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
    else $latest_skin_path = "$g4[path]/skin/latest/basic";

    $list = array();

    $rows2 = $rows * 2; // 비밀글을 제외할 때 rows가 부족할까봐 여유있게
    array_walk( $bo_tables , 'quoting');
    $bo_tables= implode( ',', $bo_tables);

    $sql = " select bo_table, wr_id from $g4[board_new_table] where bo_table in ( $bo_tables ) and wr_is_comment=0 order by bn_id desc limit 0, $rows2 ";
    $result = sql_query($sql);


    $j = 0;
    while ($row = sql_fetch_array($result)) {
     
        if ($j > $rows) break; // rows에 지정된거보다 많으면 loop를 중단. 비밀글이 많으면 rows보다 적은 열이 return됨 (그대로 효율이 중요하죠)
       
      // 게시판 테이블
        $sql3 = " select * from $g4[board_table] where bo_table = '$row[bo_table]'";
        $board = sql_fetch($sql3);

        $tmp_write_table = $g4[write_prefix] . $row[bo_table];
        $sql2 = " select * from $tmp_write_table where wr_id = '$row[wr_id]' ";
        $row2 = sql_fetch($sql2);
       
        if (!strstr($row2[wr_option], "secret")) {
            $list[$j] = get_list($row2, $board, $latest_skin_path, $subject_len);
            $list[$j][bo_name] = $board[bo_subject];
            $j++;
        }
    }
   
    $result4 = sql_fetch(" select gr_subject from $g4[group_table] where gr_id = '$gr_id' ");
    $skin_title = "$result4[gr_subject]";
    $skin_title_link = "?url=$g4[bbs_path]/new.php?gr_id=$gr_id";
   
    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
© SIRSOFT
현재 페이지 제일 처음으로