공지글만 불러오게 할 수 있나요?

공지글만 불러오게 할 수 있나요?

QA

공지글만 불러오게 할 수 있나요?

본문

도와주세요 ㅜ ㅜ

index.php 로 게시판의 최신글을 불러오기까지만 했습니다. 

공지글만 불러오게 할 수 있나요?

 

이제막 웹퍼블리싱 배운 초보입니다.

그누보드를 사용하는 홈페이지를 만들어야해서 여기저기 알아보고 있습니다.

php에 대해서는 아예 아는게 없구요 ㅜ ㅜ 

최신글 불러오기도 유투브 보면서 불러온게 전부입니다.

 

초보자에게 알려준다고 생각하시구 설명 부탁드립니다.

 

링크된 페이지로 테스트해보고 있습니다.

최신글 불러오기는 

<? echo latest("basic", "p2bbs_1", 5, 20); ?>  

이렇게 불러왔습니다.

 

이 질문에 댓글 쓰기 :

답변 4

skin/latest/basic/latest.skin.php 에서 

기본코드를


            <?php
            if ($list[$i]['icon_secret']) echo "<i class=\"fa fa-lock\" aria-hidden=\"true\"></i><span class=\"sound_only\">비밀글</span> ";
            echo "<a href=\"".get_pretty_url($bo_table, $list[$i]['wr_id'])."\"> ";
            if ($list[$i]['is_notice'])
                echo "<strong>".$list[$i]['subject']."</strong>";
            else
                echo $list[$i]['subject'];
            echo "</a>";
            
            if ($list[$i]['icon_hot']) echo "<span class=\"hot_icon\"><i class=\"fa fa-heart\" aria-hidden=\"true\"></i><span class=\"sound_only\">인기글</span></span>";
            if ($list[$i]['icon_new']) echo "<span class=\"new_icon\">N<span class=\"sound_only\">새글</span></span>";
            // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
            echo $list[$i]['icon_reply']." ";
               if ($list[$i]['icon_file']) echo " <i class=\"fa fa-download\" aria-hidden=\"true\"></i>" ;
            if ($list[$i]['icon_link']) echo " <i class=\"fa fa-link\" aria-hidden=\"true\"></i>" ;
            if ($list[$i]['comment_cnt'])  echo "
            <span class=\"lt_cmt\"><span class=\"sound_only\">댓글</span>".$list[$i]['comment_cnt']."</span>";
            ?>

 

아래 코드로 교체


            <?php
            if ($list[$i]['icon_secret']) echo "<i class=\"fa fa-lock\" aria-hidden=\"true\"></i><span class=\"sound_only\">비밀글</span> ";
            echo "<a href=\"".get_pretty_url($bo_table, $list[$i]['wr_id'])."\"> ";
            echo $list[$i]['is_notice']
            echo "</a>";
            
            if ($list[$i]['icon_hot']) echo "<span class=\"hot_icon\"><i class=\"fa fa-heart\" aria-hidden=\"true\"></i><span class=\"sound_only\">인기글</span></span>";
            if ($list[$i]['icon_new']) echo "<span class=\"new_icon\">N<span class=\"sound_only\">새글</span></span>";
            // if ($list[$i]['link']['count']) { echo "[{$list[$i]['link']['count']}]"; }
            // if ($list[$i]['file']['count']) { echo "<{$list[$i]['file']['count']}>"; }
            echo $list[$i]['icon_reply']." ";
               if ($list[$i]['icon_file']) echo " <i class=\"fa fa-download\" aria-hidden=\"true\"></i>" ;
            if ($list[$i]['icon_link']) echo " <i class=\"fa fa-link\" aria-hidden=\"true\"></i>" ;
            if ($list[$i]['comment_cnt'])  echo "
            <span class=\"lt_cmt\"><span class=\"sound_only\">댓글</span>".$list[$i]['comment_cnt']."</span>";
            ?>

공지글이라는게 게시판의 공지 체크한 부분만 불러온다는건가요? 그렇다면 lastest.lib.php 파일에서 공통적으로 불러오는 부분을 쓰시던지 latest함수 부분을 복사해서 해당 공지사항만 가져오는 쿼리 부분을 추가해서 적용해 주셔야 할듯 합니다.

lib/lastest.lib.php에 있는 latest()함수를 참고 하셔서 하나 더 만들어 보세요.

        $tmp_write_table = $g5['write_prefix'] . $bo_table; // 게시판 테이블 전체이름
        $sql = " select * from {$tmp_write_table} where wr_is_comment = 0 order by wr_num limit 0, {$rows} ";
여기서 sql을

        if( $board['bo_notice'])

            $sql = " select * from {$tmp_write_table} where wr_id in ( {$board['bo_notice']}) ";

        else

            $sql = " select * from {$tmp_write_table} where wr_id in ( 0) ";

 

<?php
define('_INDEX_', true);
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if (G5_IS_MOBILE) {
    include_once(G5_THEME_MOBILE_PATH.'/index.php');
    return;
}

if(G5_COMMUNITY_USE === false) {
    include_once(G5_THEME_SHOP_PATH.'/index.php');
    return;
}

include_once(G5_THEME_PATH.'/head.php');
?>


<!-- //2021-04-06 -->
<?
  $in_table="free"; //게시판의 테이블명
  $board = get_board_db($in_table, true);
            //게시판의 설정 및 정보얻어오기 get_data.lib.php 에서 참조해서 얻어온다.
            // echo $board[bo_notice];
      //게시판의 공지사랑의 wr_id 필드 번호 , 쉽표를 기준으로 배열로되어있다
   $arr_notice = explode(',', trim($board['bo_notice']));
            //echo count($arr_notice);
   //공지사항의 총 개수

?>
<h2 class="sound_only">최신글</h2>
<div class="latest_top_wr">
     <div class="lat">
   <h2 class="lat_title"><a href="./bbs/board.php?bo_table=<?=$in_table?>"><?=$board[bo_subject]?></a></h2>
   
        <?
  //for반복문시작
  for($i=0;$i<count($arr_notice);$i++){ // 공지사항 만큼 반복
       $sql = "select * from g5_write_".$in_table." where wr_id='".$arr_notice[$i]."'";
             $result = sql_query($sql);
             $row = sql_fetch_array($result);
  ?>
   <ul>
     <li class="basic_li">
     <a href="./bbs/board.php?bo_table=<?=$in_table?>&wr_id=<?=$row[wr_id]?>">
        <?=$row[wr_subject]?><!-- 제목이다 -->
     </a>
   </ul>

        <?}//for반복문끝?>
  </div>
</div>
<!-- //2021-04-06 -->


<?php
include_once(G5_THEME_PATH.'/tail.php');
?>

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

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