테스트 사이트 - 개발 중인 베타 버전입니다

별도 php 문서를 구성 후에 게시판 리스트를 출력하고 싶어요 채택완료

itkim 6개월 전 조회 1,587

php를 잘 알지 못하는 상황에서 질문하다보니 고수님들 답답하실 수 있습니다. 양해 부탁 드립니다.

 

그누보드4에서 그누보드5로 이관하는 업무를 받아서 진행하는데 그누보드4에서 게시판 출력 내용들을 커스텀해서 사용했더라구요. 그걸 다시 쓰려니 제대로 함수가 적용이 안되서 문제가 있습니다.

 

홈페이지 내 임의 페이지에서 latest ()를 통해 게시판의 최신글을 보고 있습니다.

그 페이지에서 최신글 아래 링크를 하나 만들어서 html로 이동하고 이동된 html 페이지에서는

상단에 header.html과 하단의 footer.html을 넣고 가운데에 php 파일을 include해서 게시판을 구성하고자 하는 의도입니다.

 

<!--헤더 영역-->

  <!--header Start-->

  <div class="header_menu wrapper row1" include-html="../header.html"></div>

<!-- 해더 영역 끝 -->

<div class="news_wrapper">

  <div class="news_title" ><p>News</p></div>

  <!--  게시판 불러오기 -->

  <?

    include "../../gnuboard5/bbs/list_custom.php";

  ?>

</div>

<!-- footer -->

<div class="wrapper row4 footer_wrapper" include-html="../footer.html"></div>

 

그런데 저 list_custom.php 에서는 $board 도 $bo_table도 제대로 내용을 가져오지 못하고 있습니다.

 

그래서 제가 궁금한 건 왜 저 변수들을 제대로 못가지고 오느냐와 그냥 저 위치에 게시판을 리스트만 넣어주는 방법이 있는지 입니다.

 

단순할 것 같은데 쉽게 안되네요.

 

좋은 방법 있다면 요청 드리겠습니다

 

감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변 3개

채택된 답변
+20 포인트
6개월 전

https://sir.kr/developers_pr/13

위에 저의 전화번호 있습니다

전화하시면 도와드릴게요 

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

i
itkim
6개월 전
아 넵... 제가 일단 해보고 알려 드리겠습니다.
따로 구성하는 것도 생각해 보고 있었는데 기존 코딩이 더 효율적일 것으로 생각하고 있어서 어떻게든 해 보고 싶었거든요.

따로 구성해서 진행해 보겠습니다.

고맙습니다.

댓글을 작성하려면 로그인이 필요합니다.

itkim
6개월 전

아 도움 주시는데 많은 걸 보여드리지 못했네요.

 

list.php를 커스텀 한 것 같은데.... 

 

<?

$g5_dir='../../gnuboard5/'; //기존 페이지 기준으로 root 의 상대경로

 

$common_dir = $g5_dir."common.php";

$config_dir = $g5_dir."config.php";

 

include_once($common_dir);

include_once($config_dir);

 

if (!defined("_GNUBOARD_"))     exit; // 개별 페이지 접근 불가

 

// 분류 사용 여부

$is_category = false;

if ($board[bo_use_category])

{

    $is_category = true;

    $category_location = $g5_dir."bbs/board.php?bo_table=$bo_table&sca=";

    $category_option = get_category_option($bo_table); // SELECT OPTION 태그로 넘겨받음

}

 

$sop = strtolower($sop);

if ($sop != "and" && $sop != "or")

    $sop = "and";

 

// 분류 선택 또는 검색어가 있다면

$stx = trim($stx);

if ($sca || $stx)

{

    $sql_search = get_sql_search($sca, $sfl, $stx, $sop);

 

    // 가장 작은 번호를 얻어서 변수에 저장 (하단의 페이징에서 사용)

    $sql = " select MIN(wr_num) as min_wr_num from $write_table ";

    $row = sql_fetch($sql);

    $min_spt = $row[min_wr_num];

 

    if (!$spt) $spt = $min_spt;

 

    $sql_search .= " and (wr_num between '".$spt."' and '".($spt + $config[cf_search_part])."') ";

 

    // 원글만 얻는다. (코멘트의 내용도 검색하기 위함)

    $sql = " select distinct wr_parent from $write_table where $sql_search ";

    $result = sql_query($sql);

    $total_count = mysql_num_rows($result);

}

else

{

    $sql_search = "";

 

    $total_count = $board[bo_count_write];

}

 

$total_page  = ceil($total_count / $board[bo_page_rows]);  // 전체 페이지 계산

if (!$page) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)

$from_record = ($page - 1) * $board[bo_page_rows]; // 시작 열을 구함

 

// 관리자라면 CheckBox 보임

$is_checkbox = false;

if ($member[mb_id] && ($is_admin == "super" || $group[gr_admin] == $member[mb_id] || $board[bo_admin] == $member[mb_id]))

    $is_checkbox = true;

 

// 정렬에 사용하는 QUERY_STRING

$qstr2 = "bo_table=$bo_table&sop=$sop";

 

if ($board[bo_gallery_cols])

    $td_width = (int)(100 / $board[bo_gallery_cols]);

 

// 정렬

// 인덱스 필드가 아니면 정렬에 사용하지 않음

//if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {

if (!$sst)

{

    if ($board[bo_sort_field])

        $sst = $board[bo_sort_field];

    else

        $sst  = "wr_num, wr_reply";

    $sod = "";

}

else {

    // 게시물 리스트의 정렬 대상 필드가 아니라면 공백으로 (nasca 님 09.06.16)

    // 리스트에서 다른 필드로 정렬을 하려면 아래의 코드에 해당 필드를 추가하세요.

    // $sst = preg_match("/^(wr_subject|wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";

    $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";

}

 

if ($sst)

    $sql_order = " order by $sst $sod ";

 

if ($sca || $stx)

{

    $sql = " select distinct wr_parent from $write_table where $sql_search $sql_order limit $from_record, $board[bo_page_rows] ";

}

else

{

    $sql = " select * from $write_table where wr_is_comment = 0 $sql_order limit $from_record, $board[bo_page_rows] ";

}

$result = sql_query($sql);

 

// 년도 2자리

$today2 = $g5[time_ymd];

 

$list = array();

$i = 0;

 

if (!$sca && !$stx)

{

    $arr_notice = explode("\n", trim($board[bo_notice]));

    for ($k=0; $k<count($arr_notice); $k++)

    {

        if (trim($arr_notice[$k])=='') continue;

 

        $row = sql_fetch(" select * from $write_table where wr_id = '$arr_notice[$k]' ");

 

        if (!$row[wr_id]) continue;

 

        $list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);

        $list[$i][is_notice] = true;

 

        $i++;

    }

}

 

$k = 0;

 

while ($row = sql_fetch_array($result))

{

    // 검색일 경우 wr_id만 얻었으므로 다시 한행을 얻는다

    if ($sca || $stx)

        $row = sql_fetch(" select * from $write_table where wr_id = '$row[wr_parent]' ");

 

    $list[$i] = get_list($row, $board, $board_skin_path, $board[bo_subject_len]);

    if (strstr($sfl, "subject"))

        $list[$i][subject] = search_font($stx, $list[$i][subject]);

    $list[$i][is_notice] = false;

    //$list[$i][num] = number_format($total_count - ($page - 1) * $board[bo_page_rows] - $k);

    $list[$i][num] = $total_count - ($page - 1) * $board[bo_page_rows] - $k;

 

    $i++;

    $k++;

}

 

$write_pages = get_paging($config[cf_write_pages], $page, $total_page, $g5_dir."bbs/board.php?bo_table=$bo_table".$qstr."&page=");

 

$list_href = '';

$prev_part_href = '';

$next_part_href = '';

if ($sca || $stx)

{

    $list_href = $g5_dir."bbs/board.php?bo_table=$bo_table";

 

    //if ($prev_spt >= $min_spt)

    $prev_spt = $spt - $config[cf_search_part];

    if (isset($min_spt) && $prev_spt >= $min_spt)

        $prev_part_href = $g5_dir."bbs/board.php?bo_table=$bo_table".$qstr."&spt=$prev_spt&page=1";

 

    $next_spt = $spt + $config[cf_search_part];

    if ($next_spt < 0)

        $next_part_href = $g5_dir."bbs/board.php?bo_table=$bo_table".$qstr."&spt=$next_spt&page=1";

}

 

$write_href = "";

if ($member[mb_level] >= $board[bo_write_level])

    $write_href = $g5_dir."bbs/write.php?bo_table=$bo_table";

 

$nobr_begin = $nobr_end = "";

if (preg_match("/gecko|firefox/i", $_SERVER['HTTP_USER_AGENT'])) {

    $nobr_begin = "<nobr style='display:block; overflow:hidden;'>";

    $nobr_end   = "</nobr>";

}

 

// RSS 보기 사용에 체크가 되어 있어야 RSS 보기 가능 061106

$rss_href = "";

if ($board[bo_use_rss_view])

    $rss_href = $g5_dir."bbs/rss.php?bo_table=$bo_table";

 

$stx = get_text(stripslashes($stx));

include_once("$board_skin_path/basic/list.skin.php");

?>

 

 

그런데 문제는 해당 list_custom.php를 이용해서 각각 게시판에 있는 걸 $bo_table 정보를 넘겨 주면서 보여주도록 구성되어 있습니다.
그러다 보니 php에서 $bo_table 이 필요한데 이게 null로 넘어간다는 거죠..

 

그누4에서는 잘 되는게 그누5에서는 안되니... 제가 좀 답답했습니다.

 

그냥 각 게시판을 보여주는 php 를 따로따로 구성해도 될 거 같아서 위에 말씀해 주신 코드로 만들어 볼께요.

 

답변 고맙습니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

균이
6개월 전
php 를 따로따로 구성해도 될 거 같아서<===한개의 게시판이 아니고 여러 게시판에 적용하려면
php를 따로 구성할 것이 아니라 링크를 만들때 bo_table을 전달하도록 만들면 간단합니다

list_custom.php를 include하는 화일명을 php로 만들고(예 test.php) 링크를 만들면 됩니다

./bbs/test.php?bo_table=~~~

댓글을 작성하려면 로그인이 필요합니다.

6개월 전

 list_custom.php가 중요한데 어떤 코드로 이루어져 있는지 보아야 도움 답변을 할 수 있겠습니다

list_custom.php를 다음처럼 해보세요

<?php

$_REQUEST['bo_table']='free';

include "_common.php";

$qq =sql_query("select * from $write_table order by wr_num limit 0,15");

while($row=sql_fetch_array($qq)) print_r($row);

 

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인