최신글 공지사항을 제일 먼제 출력하고 아래는 리스터 순서대로

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
최신글 공지사항을 제일 먼제 출력하고 아래는 리스터 순서대로

QA

최신글 공지사항을 제일 먼제 출력하고 아래는 리스터 순서대로

본문

저는 뉴스 사이트를 운영합니다. 한 게시판에서 두개의 뉴스형 최신글을 불러와 메인 페이지를 구성하는데 제일 먼저 공지만 축출하여 헤드라인으로 사용하고 있고요(글자크기등 변경). 아래에 최신글 형태로 일반 뉴스를 축출하고 있습니다.

그런데 아래에 헤드라인에 이미 추출된 공지글이 중복해서 나오게 됩니다. 아래 그림을 참고 하시고  한꺼번에 공지와 함께 추축할 수는 없는지요. 물론 공지는 글자 크기 변경등이 가능하면 좋겠네요.


제가 사용하는 최신글 소스를 공개 합니다.
1은 공지만 불러오기. 2는 전체 불러오기 입니다.

공지.gif


1.

<meta name="generator" content="Namo WebEditor(Trial)">
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
 
 if($notice>0) {
foreach( $list as $key => $value) $tmp_notice[$key] = $value['is_notice'] *100000 + $value['wr_id'];
 array_multisort($tmp_notice, SORT_DESC, $list);
}

$rows = count($list);
$style_name = "mw-group-$bo_table-$rows-$subject_len";
?>
<style type="text/css">
#<?=$style_name?> { clear:both; margin:1; border:1px solid #e1e1e1; }
#<?=$style_name?> .item { clear:both; display:none; }
#<?=$style_name?> .file-img-b { width:90px; height:60px; border:0px solid #e1e1e1; border-left:0; }
#<?=$style_name?> .subject { clear:both; height:30px; color:#666666; font-weight:bold; font-size:13px; }
#<?=$style_name?> .subject a { color:black; text-decoration:none; }
#<?=$style_name?> .prev { float:left; margin:0 0 0 -4px; cursor:pointer; }
#<?=$style_name?> .next { float:left; margin:0 0px 0 0; cursor:pointer; }
#<?=$style_name?> .link { float:left; margin:0 0 0 5px; text-align:center; }
</style>

<div id="<?=$style_name?>">

<? for ($i=0; $i<$rows; $i++) { ?>
<table width="99%" border="0" cellspacing="0" cellpadding="3" style="margin-top:4px; margin-bottom:4px; padding:5px;" height="96">
        <tr>
 <?
$img = "$g4[path]/data/file/$bo_table/thumb/{$list[$i][wr_id]}";
if (!@file_exists($img)) $img = "";
if (!$list[$i][wr_id]) $img = "";
if (@is_dir($img)) $img = "";
?>
<? if ($img) { ?>
<td width="1747" colspan="3" height="49">

<table border="0" width="100%" cellpadding="0" cellspacing="0">
                    <tr>
<td width="20" height="23"> </td>
 <td width="1174" height="23">                           
<p style="line-height:150%;"><a href="<?=$list[$i][href]?>"><b><font color="black"><span style="font-size:16pt;"><?=$list[$i][wr_3]?></span></font></b></a></p>
</td></tr>                    <tr>
 <td width="20" height="24"> </td>
<td width="1174" height="24"><p><a href="<?=$list[$i][href]?>"><b><font face="궁서" color="#333333"><span style="font-size:11pt;"><?=$list[$i][wr_1]?></span></font></b></a></p></td>
</tr></table>
</td>
<? } ?>
  </tr>
 <tr>
<td width="72" height="43"><p align="left"><a href="<?=$list[$i][href]?>"><img src="<?=$img?>" class="file-img-b"></a></p></td>
 <td width="3" height="43"> </td>
<td width="1660" height="43" valign="top" background="http://tynews.kr/img/line2.gif">
<span style="color:#333333; font-size:12px"><?=cut_str(strip_tags($list[$i]['wr_2']),280,"...")?></span>
</td></tr></table>
    <? } ?>
<? if (count($list) == 0) { echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td></td>
  </tr>
</table>"; } ?>

</div>




2.

<meta name="generator" content="Namo WebEditor(Trial)">
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
 
 if($notice>0) {
foreach( $list as $key => $value) $tmp_notice[$key] = $value['is_notice'] *100000 + $value['wr_id'];
 array_multisort($tmp_notice, SORT_DESC, $list);
}

$rows = count($list);
$style_name = "mw-group-$bo_table-$rows-$subject_len";
?>
<style type="text/css">
#<?=$style_name?> { clear:both; margin:1; border:1px solid #e1e1e1; }
#<?=$style_name?> .item { clear:both; display:none; }
#<?=$style_name?> .file-img-b { width:90px; height:60px; border:0px solid #e1e1e1; border-left:0; }
#<?=$style_name?> .subject { clear:both; height:30px; color:#666666; font-weight:bold; font-size:13px; }
#<?=$style_name?> .subject a { color:black; text-decoration:none; }
#<?=$style_name?> .prev { float:left; margin:0 0 0 -4px; cursor:pointer; }
#<?=$style_name?> .next { float:left; margin:0 0px 0 0; cursor:pointer; }
#<?=$style_name?> .link { float:left; margin:0 0 0 5px; text-align:center; }
</style>

<div id="<?=$style_name?>">

<? for ($i=0; $i<$rows; $i++) { ?>
<table width="99%" border="0" cellspacing="0" cellpadding="3" style="margin-top:4px; margin-bottom:4px; padding:5px;" height="96">
        <tr>
 <?
$img = "$g4[path]/data/file/$bo_table/thumb/{$list[$i][wr_id]}";
if (!@file_exists($img)) $img = "";
if (!$list[$i][wr_id]) $img = "";
if (@is_dir($img)) $img = "";
?>
<? if ($img) { ?>
<td width="1747" colspan="3" height="49">

<table border="0" width="100%" cellpadding="0" cellspacing="0">
                    <tr>
<td width="20" height="23"> </td>
 <td width="1174" height="23">                           
<p style="line-height:150%;"><a href="<?=$list[$i][href]?>"><b><font color="black"><span style="font-size:13pt;"><?=$list[$i][wr_3]?></span></font></b></a></p>
</td></tr>                    <tr>
 <td width="20" height="24"> </td>
<td width="1174" height="24"><p><a href="<?=$list[$i][href]?>"><b><font face="궁서" color="#333333"><span style="font-size:11pt;"><?=$list[$i][wr_1]?></span></font></b></a></p></td>
</tr></table>
</td>
<? } ?>
  </tr>
 <tr>
<td width="72" height="43"><p align="left"><a href="<?=$list[$i][href]?>"><img src="<?=$img?>" class="file-img-b"></a></p></td>
 <td width="3" height="43"> </td>
<td width="1660" height="43" valign="top" background="http://tynews.kr/img/line2.gif">
<span style="color:#333333; font-size:12px"><?=cut_str(strip_tags($list[$i]['wr_2']),280,"...")?></span>
</td></tr></table>
    <? } ?>
<? if (count($list) == 0) { echo "<table width='100%' border='0' cellspacing='0' cellpadding='0'>
  <tr>
    <td></td>
  </tr>
</table>"; } ?>

</div>

이 질문에 댓글 쓰기 :

답변 1

1번과 2번의 차이를 모르겠네요
if($notice> 0) <-- 이건 뭔가요? 남이 보고 이해할 수 있도록 질문을..

원본 latest는 다른 게시판용으로 사용하고 latest_notice()를 하나 만드세요
<?=latest_notice(~~~~~,'notice');?> <---마지막에 notice 넣으면 공지만 추출
<?=latest_notice(~~~~~);?> <---마지막 인자가 없으면 일반글만 추출

function latest_notice(~~){
global $g4;
$board=sql_fetch("select bo_notice from $g4[board_table] where bo_table='$bo_table'");
 $arr_notice = explode("\n", trim($board[bo_notice]));
$notice_id=implode(',', $arr_notice);
if($notice_id){
  if($options =='notice') $add_qry =" and wr_id IN($notice_id) "; //공지만 추출
  else $add_qry =" and wr_id not IN($notice_id) "; //공지아닌 것만 추출
}
~~~
~~~
$sql = " select * from $tmp_write_table where wr_is_comment = 0 $add_qry order by wr_num limit 0, $rows ";
$result =~~~
~~
~~
}

출력은 일반 스킨과 동일하게 하면 됩니다
답변을 작성하시기 전에 로그인 해주세요.
전체 5
QA 내용 검색

회원로그인

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