드디어 질문을할수잇는포인트가 되었습니다, 도와주세요 고수님들,,^^ > 그누4 질문답변

그누4 질문답변

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

드디어 질문을할수잇는포인트가 되었습니다, 도와주세요 고수님들,,^^ 정보

드디어 질문을할수잇는포인트가 되었습니다, 도와주세요 고수님들,,^^

본문

아래는 불당님의 회원이 스크랩한 것을 최신글로 보여주기
팁입니다,,,
여기서 이미지까지 나오게 할려면,, 어떻게 해야할까요?
추가적으로,, 필드1을 사용할경우, 그것도 나오게할려면,,
아,, 늘 도움만 받는 질문쟁이 입니다,,
 
천상재회님의 놀라운 파워팁에 붙여서 써비스 합니다. 
저희 사이트의 대문에 있는 팁 입니다.

공지게시판을 최신글로 보여주는 것은 한계가 있고 여러 게시판에서 주요한
글들을 뽑아서 보여주기 위해서 flag를 설정해서 추출하는 것도 솔직히 별로
바람직한 기법은 아니라서 운영자가 스크랩한 것을 최근글로 보이게 했어요.

사용법
<? echo show_scrap_list("userid""basic""Notice..."6); ?> 

아래의 코드는 적당한 곳에 넣으면 되겠죠?

//// 운영자 스크랩 리스트 표시해주는 함수
function show_scrap_list($user_id, $skin_dir, $title, $limit_count=10)
{
    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();

    // 게시판 제목 설정
    $board['bo_subject'] = $title;

    $query  = "SELECT SC.bo_table, SC.wr_id FROM g4_scrap SC ";
    $query .= "WHERE mb_id='".$user_id."' ";
    $query .= "ORDER BY ms_id DESC ";
    $query .= "LIMIT ".$limit_count;
    $sql = mysql_query($query);

    $i = 0;
    while( $s_row = mysql_fetch_array($sql) )
    {
        $query = "SELECT * FROM `g4_write_".$s_row['bo_table']."` WHERE wr_id='".$s_row['wr_id']."'";
        $w_row = mysql_fetch_array(mysql_query($query));

        $list[$i]['subject'] = cut_str($w_row['wr_subject'], 40);
        $list[$i]['href'] = $g4['bbs_path']."/board.php?bo_table=".$s_row['bo_table']."&wr_id=".$s_row['wr_id'];

    // 날짜 표시하기        
    $list[$i]['datetime'] = substr($w_row['wr_datetime'],0,10);
        $list[$i]['datetime2'] = $w_row['wr_datetime'];
        
    // 당일인 경우 시간으로 표시함
    if ($list[$i]['datetime'] == $g4['time_ymd'])
        $list[$i]['datetime2'] = substr($list[$i]['datetime2'],11,5);
    else
        $list[$i]['datetime2'] = substr($list[$i]['datetime2'],5,5);
    

        $i++;
    }

    ob_start();
    include "$latest_skin_path/latest.skin.php";
    $content = ob_get_contents();
    ob_end_clean();

    return $content;
}
?>
 
 
 
늘행복하세요^^
  • 복사

댓글 전체

http://sir.co.kr/bbs/tb.php/g4_tiptech/8515

여기 보면 첫번째 이미지 뽑는 팁 부분있죠..
그걸 요 소스의 적당한곳에.. 삽입하면.. 안될라나요?
될거라 생각되는데.. 해보지는 않았습니다..;;
// 파일을 보이게 하는 링크 (이미지, 플래쉬, 동영상)
function view_file_link($file, $width, $height, $content="")
{
    global $config, $board;
    global $g4;
    static $ids;

    if (!$file) return;

    $ids++;

    // 파일의 폭이 게시판설정의 이미지폭 보다 크다면 게시판설정 폭으로 맞추고 비율에 따라 높이를 계산
    if ($width > $board[bo_image_width] && $board[bo_image_width])
    {
        $rate = $board[bo_image_width] / $width;
        $width = $board[bo_image_width];
        $height = (int)($height * $rate);
    }

    // 폭이 있는 경우 폭과 높이의 속성을 주고, 없으면 자동 계산되도록 코드를 만들지 않는다.
    if ($width)
        $attr = " width='$width' height='$height' ";
    else
        $attr = "";

    if (preg_match("/\.($config[cf_image_extension])$/i", $file))
        // 이미지에 속성을 주지 않는 이유는 이미지 클릭시 원본 이미지를 보여주기 위한것임
        // 게시판설정 이미지보다 크다면 스킨의 자바스크립트에서 이미지를 줄여준다
        return "<img src='$g4[path]/data/file/$board[bo_table]/".urlencode($file)."' name='target_resize_image[]' onclick='image_window(this);' style='cursor:pointer;' title='$content'>";
    else if (preg_match("/\.($config[cf_flash_extension])$/i", $file))
        //return "<embed src='$g4[path]/data/file/$board[bo_table]/$file' $attr></embed>";
        return "<script>doc_write(flash_movie('$g4[path]/data/file/$board[bo_table]/$file', '_g4_{$ids}', '$width', '$height', 'transparent'));</script>";
    else if (preg_match("/\.($config[cf_movie_extension])$/i", $file))
        //return "<embed src='$g4[path]/data/file/$board[bo_table]/$file' $attr></embed>";
        return "<script>doc_write(obj_movie('$g4[path]/data/file/$board[bo_table]/$file', '_g4_{$ids}', '$width', '$height'));</script>";
}


// view_file_link() 함수에서 넘겨진 이미지를 보이게 합니다.
// {img:0} ... {img:n} 과 같은 형식
function view_image($view, $number, $attribute)
{
    if ($view['file'][$number]['view'])
        return preg_replace("/>$/", " $attribute>", $view['file'][$number]['view']);
    else
        //return "{".$number."번 이미지 없음}";
        return "";
}


/*

이부분인가요??
고수님들눈에는  참고서로 보이지만, 저같은 부지랭이 초보에게는 알수없는 문자렬로 박에 안보이네요,,, 애혀,,
get_list 부분이라고 하시니.. 거기가 아니고..

    // 가변 파일
    $list['file'] = get_file($board['bo_table'], $list['wr_id']);

요고네요..
get_list나 get_file로 검색하셨으면 금방나올 간단한 구문이네요.
저도 첨 알았슴다.. ^^;;
요거 넣으시고...
단, $board['bo_table'] 랑 $list['wr_id'] 는 위에 추출하신 쿼리문에 있는걸로 써야해요..

흠...
$s_row['bo_table'] 로 바꾸고...
또..
$w_row['wr_id'] 하셔야 겠네요..


그리고 최근게시물에서.. 흠..
아..
 최근게시물에서 이미지 불러올때 경로로 인해서 보테이블 불러와야하니까..
$list[$i]['bo_table'] = $s_row['bo_table'];
요거 정의도 있어야하겠네요..

다시.. 최근게시물가서...
$img = "$g4[path]/data/file/" .$list[$i][bo_table] ."/" .$list[$i][file][0][file];

이러면.. 파일 경로 뜨니까.. 이걸 이미지로 뽑으면 될듯...

막 이미지 있으면 뭐고 없으면.. 뭐고 하는 구문은 전 모릅니다..;;;;
불당님의 소스에,,
// 가변 파일
        $list['file'] = get_file($s_row['bo_table'], $w_row['wr_id']);
이런식으로 추가햇구요,,
그런대
최신글에서 삽입하는부분 하여보니,, 제가 분명 잘못삽입한검니다,,
이건확실함니다,,,
어재든
하얀 화면만 나오네요^^


원 최신글, 파일이,,
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가

$cols  = 6; //  이미지 가로갯수 //  이미지 세로 갯수는 메인에서 지정(총 이미지 수)
$image_h  = 10; // 이미지 상하 간격

$col_width = (int)(99 / $cols);

$data_path = $g4[path]."/data/file/$bo_table";
$thumb_path = $data_path.'/thumb';
?>
<style type="text/css">
<!--
.data  { font-family:돋움; font-size:8pt; color:#999999; }
-->
</style>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <!-- 최신글 제목 -->
  <tr><td>
<table width="100%" height="28" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
  <td><img src="<?=$latest_skin_path?>/img/bullet00.gif" width="12" height="12" align="absmiddle">
<strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><?=$board[bo_subject]?></a></strong></td>
  <td align="right"><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src="<?=$latest_skin_path?>/img/noti_box_bt.gif" width="49" height="14" border="0"></a></td>
</tr>
  </table></td>
  </tr>
  <tr>
<td height="1" bgcolor="cccccc"> </td>
  </tr>
  <tr>
<td height="2" bgcolor="E9E5E5"> </td>
  </tr>
</table>
</td></tr>

<tr><td height='10'></td></tr>
<tr>
<td align='center'>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>

<? for ($i=0; $i<count($list); $i++) {
  if ($i>0 && $i%$cols==0) { echo "</tr><tr><td colspan='$cols' height='$image_h'></td></tr><tr>"; }
?>

<td width="<?=$col_width?>%" align="center" valign='top'>

<?
$image = $list[$i][file][0][file]; //원본
$img=$data_path. "/".$image;  //썸네일이 없을경우 원본출력
$thumb = $thumb_path. "/". $list[$i][wr_id];

  if ( file_exists($thumb) )
$img = $thumb;
 
    $style = "font-family:돋움; font-size:9pt; color:#636363;";
    if ($list[$i][icon_new])
    $style = "style='font-family:돋움; font-size:9pt; color:#006F00;' ";
$subject = "<span $style>".cut_str($list[$i][subject],15)."</span>"; //제목 글자수 자르기

$bg = "";  //새글?
    if ($list[$i][icon_new])
        $bg="la_top_2.gif";
    else
        $bg="la_top_1.gif";

    echo $list[$i][icon_reply] . " ";

echo "<table width='100' cellpadding='0' cellspacing='0' border='0'>";
echo " <tr><td valign='top' align='center'><a href=\"javascript:;\" OnClick=\"popupImage('$g4[path]/data/file/$bo_table/$image')\" onFocus=\"this.blur();\" title=\"{$list[$i][subject]}\"><img src='$img' width='100' height='70' border='0'></a></td></tr>";
echo " <tr><td height='21'><a href='{$list[$i]['href']}'>{$subject}</a></td></tr></table>";
?>
</td>
<? } ?>

<?
$cnt = ($i%$cols);
for ($k=$cnt; $k<$cols && $cnt; $k++) {
    echo "<td width=$col_width%>&nbsp;</td>";
}
?>

  <? if (count($list) == 0) { echo "<td height=80 align=center>게시물이 없습니다.</td>"; } ?>
  </tr>
</table></td>
</tr>
</table>

<script language="javascript">
function popupImage(imageURL){
imageHandle=open("","popupForImage","toolbar=no,location=no,status=no,manubar=no,scrollbars=no,resizable=no,width=100,height=100,top=0,left=0");
  imageHandle.document.write("<title>  </title>");
  imageHandle.document.write("<style>");
  imageHandle.document.write("*{margin:0;padding:0;border:0;}");
  imageHandle.document.write("</style>");
  imageHandle.document.write("<img src=\""+imageURL+"\" onload=\"window.resizeTo(this.width+6,this.height+55);\" onclick=\"self.close();\" style=\"cursor:hand;\" title=\"클릭하면 닫힙니다.\">");
}
</script>

이거 거든요,,  제가 아무리해도 흰색화면만,,
정말 아무것도 모르고 고수님들 귀찬게 해드리는 것 같아 죄송함니다,
위 최상단의 불당님 소스 보시면..

        $list[$i]['subject']
        $list[$i]['href']
        $list[$i]['datetime']
        $list[$i]['datetime2']

이거 외에는 설정되어 있지 않습니다.
즉 $bo_table 이라던가.. $board[bo_table] 라던가..
lastest 스킨에서 이걸 직접 쓰신다고 해도..  스킨은 그 함수를 읽어 오지 못합니다.
정의되어 있지 않으니까요..

그래서  이미지 경로를 보기 위해 bo_table을 설정하기위에..
$list[$i]['bo_table'] = $s_row['bo_table'];
이부분도 넣으라고 말씀드린겁니다.
그리고 보테이블 불러오는 부분은
$list[$i]['bo_table']로 수정해보세요..
© SIRSOFT
현재 페이지 제일 처음으로