M

이미지 클릭함 새창 띄우기 최신글에 응용하기..2.60

Mando
· 22년 전 · 2298 · 4
아래글의 1번과 2번 작업이 이루어졌다는 가정하에....
1. gnu 폴더에 있는 lib.inc.php를 열어서..
관리자님이 만들어 주신 최신글 뽑기를 쓸쩍 긁어서 마우스 우측버튼(ctrl+c) 누르고 복사(ctrl+c)  합니다...
// 최신글을 추출한다.
function latest($skin_dir='', $bo_table, $rows=10, $len=40)
{
.....중간생략.....  

   include "$latest_skin/latest_tail.skin.php";
}
요기까지.........


2. 같은 폴더에 있는 libdev.inc.php(개발자용이라고 했는데...요기선 복사자용...)를 열어서
붙여넣기(ctrl+v)를 합니다.. 그다음에는 아래와 같이 수정합니다
// 최신글을 추출한다.
function latest2($skin_dir='', $bo_table, $rows=10, $len=40)//function latest를 function latest2로
{
   global $latest_skin, $cfg, $reldir, $bbsdir;

   include_once "$reldir/$bbsdir/gblayer.php";

   // 스킨디렉토리값이 넘어왔다면
   if ($skin_dir) {
       $latest_skin = "$reldir/$bbsdir/$cfg[dir_skin]/latest/$skin_dir";
   }

   $sql = " select * from $cfg[table_board] where bo_table = '$bo_table' ";
   $bo = sql_fetch_array($sql);
   $bo_subject = $bo[bo_subject];
   include "$latest_skin/latest_head.skin.php";

   $sql = " select *
             from {$cfg[write_table_prefix]}{$bo_table}
             where wr_comment = 0
             order by wr_num, wr_datetime desc limit 0, $rows ";
   $result = sql_query_error($sql);
   for ($i=0; $row = mysql_fetch_array($result); $i++) {
       $wr_subject = conv_subject($row[wr_subject], $len,"…");
       $wr_name = gblayer($row[mb_id], cut_str($row[wr_name],10), $row[wr_email], $row[wr_homepage], "$reldir/$bbsdir");
       $wr_date = substr($row[wr_datetime],2,8);
아래에 추가합니다..
       $wr_content=$row[wr_content];
    if($wr_content) $wr_content  = get_text(cut_str($row[wr_content], 200, '.......'));//본문내용을 최신글에 보여주기
                                                                                                                      위해  숫자를 조정하면 글자수  
                                                                                                                       조 정댑니다..  
       $file1_image = "$reldir/$cfg[dir_file]/$bo_table/$row[wr_file1]";// 이미지를 보여주기위해
&nbsp; &nbsp; &nbsp; if($file1_image) $image_href = "<a href='javascript:;'onclick=\"view('$reldir/$cfg[dir_file]/$bo_table/$row[wr_file1]')\">"; // 새창이미지 보여주기 위해
요기까지...


&nbsp; &nbsp; &nbsp; // new 이미지
&nbsp; &nbsp; &nbsp; &nbsp;$icon_new = "";
&nbsp; &nbsp; &nbsp; &nbsp;if ($row[wr_datetime] >= date("Y-m-d H:i:s", time() - $bo[bo_new] * 3600)) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$icon_new = "<img src='$latest_skin/icon_new.gif' align=absmiddle>";
&nbsp; &nbsp; &nbsp; &nbsp;}

&nbsp; &nbsp; &nbsp; &nbsp;// 코멘트 카운트
&nbsp; &nbsp; &nbsp; &nbsp;$commentcnt = "";
&nbsp; &nbsp; &nbsp; &nbsp;if ($row[wr_commentcnt] > 0) {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$commentcnt = "($row[wr_commentcnt])";
&nbsp; &nbsp; &nbsp; &nbsp;}

&nbsp; &nbsp; &nbsp; &nbsp;$a_list_link = "$reldir/$bbsdir/gnuboard.php?bo_table=$bo_table&wr_id=$row[wr_id]";
&nbsp; &nbsp; &nbsp; &nbsp;include "$latest_skin/latest_main2.skin.php";// 요기에서 중요 ....../latest_main2.skin.php로 이름을 바꾸어 줍니다
&nbsp; &nbsp;}
&nbsp; &nbsp;mysql_free_result($result);

&nbsp; &nbsp;$show_nodata_begin = "";
&nbsp; &nbsp;$show_nodata_end = "";
&nbsp; &nbsp;if ($i>0) {
&nbsp; &nbsp; &nbsp; &nbsp;$show_nodata_begin = "<!--";
&nbsp; &nbsp; &nbsp; &nbsp;$show_nodata_end = "-->";
&nbsp; &nbsp;}
&nbsp; &nbsp;include "$latest_skin/latest_tail.skin.php";
}
저장후 업로드....

2. 최신글 스킨으로 지정한 스킨폴더에 (gnu/bbs/skin/latest/관리자로그인시 기본환경설정에 최신글 스킨 지정한 이름 폴더) latest_main.skin.php를 열어서 //아래는 제경우 입니다..

<tr height=25>
&nbsp; &nbsp;<!--<td bgcolor=#ffffff width=60><?=$wr_date?></td>-->
&nbsp; &nbsp;<td bgcolor=#ffffff width=40 align=center valign=middle> &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;<?=$image_href?><img src='<?=$file1_image?>' width=120 height=96 border=0></a></td>
//////바로 윗줄과 같이 <?=$image_href?><?=$file1_image?>를 넣어 그림의 위치 구성을 합니다..
.
.
.중략 &nbsp; &nbsp; &nbsp; &nbsp;
<a href='<?=$a_list_link?>'><b><?=$wr_subject?> </b><font style='font-size:8pt; color:999999;'><?=$commentcnt?>
// 제목부부분이 보여질곳에 ><?=$wr_subject?>를 넣어 제목의 위치 구성을 합니다..

</font></a></td>
&nbsp; &nbsp; &nbsp; </tr>
&nbsp; &nbsp; &nbsp; <tr>
&nbsp; &nbsp; &nbsp; &nbsp; <td height=55 colspan=2><?=$wr_content?></td>
//글내용이 보여질 곳에 <?=$wr_content?>를 넣어 글내용의 위치 구성을 합니다..

중략....
&nbsp;
&nbsp; &nbsp;<!--<td bgcolor=#ffffff width=100 align=center><?=$mb_icon?><?=$wr_name?></td>-->
&nbsp; &nbsp;<td bgcolor=#ffffff width=40 align=center><font color=999999><?=$mmdd?></font></td>
</tr>
<tr>
&nbsp; &nbsp;<td colspan=3 height=1 background='<?=$latest_skin?>/line_width.gif'></td>
</tr>

...이때에 중요한것은 다른이름으로 저장합니다... latest_main2.skin.php로 ....
한가지더 중요한것은 latest_head.skin.php와 &nbsp;latest_tail.skin.php 그냥 있던걸로 쓴다는 사실 입니다...
그러므로 위 두파일의 구성과 어긋나면 테이블이 깨져 보일수도 있으니 신경 쓰기 바랍니다...

다른 이름(latest_main2.skin.php로)으로 저장후 &nbsp;최신글 스킨 폴더에 업로드합니다.


3. 최신글이 보여질 위치에
latest2('','게시판 아이디', 글수, 제목글자수);
를 넣습니다.. 보여질 본문의 글자수는 libdev.inc.php에서 조정합니다...저위에 표시를....
EX : &nbsp;latest5('','kissmyass', 1, 55);<---첫째를 비워놓으면 관리자모드에서 지정한 스킨이 그대로 사용 댑니다..


이상입니다....
장장 한시간에 걸쳐서 썼더니(무식해서)...로그아웃 되었네요....그래서 다시&#50043;음....
|

댓글 4개

MMando
22년 전
2.61 에서 수정할 부분
====================================
2번내용중
=======================================
include_once "$reldir/$bbsdir/gblayer.php"; ====> include_once "$reldir$bbsdir/gblayer.php";

$latest_skin = "$reldir/$bbsdir/$cfg[dir_skin]/latest/$skin_dir";====>$latest_skin = "$reldir$bbsdir/$cfg[dir_skin]/latest/$skin_dir";

$a_list_link = "$reldir/$bbsdir/gnuboard.php?bo_table=$bo_table&wr_id=$row[wr_id]";
======>$a_list_link = "$reldir$bbsdir/gnuboard.php?bo_table=$bo_table&wr_id=$row[wr_id]";

$file1_image = "$reldir/$cfg[dir_file]/$bo_table/$row[wr_file1]";// 이미지를 보여주기위해
=====> $file1_image = "$reldir$cfg[dir_file]/$bo_table/$row[wr_file1]";// 이미지를 보여주기위해
MMando
22년 전
$wr_content=$data[wr_content];
if($wr_content) $wr_content = get_text(cut_str($row[wr_content], 200, '.......'));//본문내용을 최신글에 보여주기
위해 숫자를 조정하면 글자수
조 정댑니다..

이부분에서
$wr_content=$data[wr_content];======>$wr_content=$row[wr_content];로 바꺼야ㅔ 보이는 것 같군요....
역시 고차원의 고급 노가다 같군요..
수고하셨습니다..
만도님 좋은 팁들 감사합니다..
설사 노가다의 산물이라 할지라도..부럽습니다.
내가 보기엔 고차원의 고급 노가다 같군요.. 하하.

댓글 작성

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

로그인하기
🐛 버그신고