스크롤되는 최근게시물 > 그누4 질문답변

그누4 질문답변

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

스크롤되는 최근게시물 정보

스크롤되는 최근게시물

본문

userfunction.lib 연후아빠님이 추천한 그룹최신글 뽑기(잘 됩니다.^^)
 
<?
if (!defined('_GNUBOARD_')) exit;
/// 함수 정의 시작
// 최신글 추출 - 선택한 그룹별로 원하는 수만큼 보여줌
function latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $options="")
{
global $config;
global $g4;
$list = array();
$limitrows = $rows;
list($wheres,$orderby,$img_width,$img_height,$width,$height,$mod,$wdirect) = explode(",", $options);
$img_width=trim($img_width);
$img_height=trim($img_height);
$width=trim($width);
$height=trim($height);
$mod=trim($mod);
$wdirect=trim($wdirect);
$sqlgroup = " select bo_table, bo_subject from $g4[board_table] where gr_id = '$gr_id' and  bo_use_search=1 order by bo_order_search";
$rsgroup = sql_query($sqlgroup);
if ($skin_dir)
$latest_skin_path = "$g4[path]/skin/latest/$skin_dir";
else
$latest_skin_path = "$g4[path]/skin/latest/$config[cf_latest_skin]";
for ($j=0, $k=0; $rowgroup=sql_fetch_array($rsgroup); $j++) {
$bo_table = $rowgroup[bo_table];
// 테이블 이름구함
$sql = " select * from {$g4[board_table]} where bo_table = '$bo_table'";
$board = sql_fetch($sql);
$tmp_write_table = $g4[write_prefix] . $bo_table; // 게시판 테이블 실제이름
// 옵션에 따라 정렬
$sql = "select * from $tmp_write_table where wr_is_comment = 0 ";
$sql .= (!$category) ? "" : " and ca_name = '$category' ";
$sql .= (!$orderby) ? "  order by wr_id desc " : "  order by $orderby desc, wr_id desc ";
$sql .= " limit $limitrows";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++, $k++) {
if(!$orderby) $op_list[$k] = $row[wr_datetime];
else  {
$op_list[$k] = is_string($row[$orderby]) ? sprintf("%-256s", $row[$orderby]) : sprintf("%016d", $row[$orderby]);
$op_list[$k] .= $row[wr_datetime];
}
$list[$k] = get_list($row, $board, $latest_skin_path, $subject_len);
$list[$k][bo_table] = $board[bo_table];
$list[$k][bo_subject] = $board[bo_subject];
$list[$k][bo_wr_subject] = cut_str($board[bo_subject] . $list[$k][wr_subject], $subject_len);
}
}
if($k>0) array_multisort($op_list, SORT_DESC, $list);
if($k>$rows) array_splice($list, $rows);
ob_start();
include "$latest_skin_path/latest.skin.php";
$content = ob_get_contents();
ob_end_clean();
return $content;
}
/// 함수 정의 끝
?>
 
 
 
관리자님이 올리신 스크롤되는 최신글
 
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가
// 위로 스크롤되는 최신글
// 사용법 :
// 스킨, 게시판아이디, 출력라인, 글자수, "몇개라인,라인높이"
// latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")
// $rows(출력라인)는 $line_mod의 2의 배수 이상으로 설정하셔야 합니다.
// 유니크 값 (최신글은 한페이지에 여러개 둘 수 있으므로... 자바스크립트에서 함수, 변수 충돌을 방지)
$uni = md5(uniqid(rand(), true));
list($line_mod, $height) = explode(",", $options);
$box_height = (int)$line_mod * (int)$height;
?>
<table width=100% cellpadding=0 cellspacing=0 border=0>
<colgroup width=14>
<colgroup>
<colgroup width=37>
<colgroup width=14>
<tr>
    <td><img src='<?=$latest_skin_path?>/img/latest_t01.gif'></td>
    <td background='<?=$latest_skin_path?>/img/bg_latest.gif'>  <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><?=$board[bo_subject]?></a></strong></td>
    <td background='<?=$latest_skin_path?>/img/bg_latest.gif'><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/more.gif' border=0></a></td>
    <td><img src='<?=$latest_skin_path?>/img/latest_t02.gif'></td>
</tr>
<tr><td colspan=4 style='padding-left:20px; padding-right:20px; padding-top:5px; padding-bottom:5px;'>
<? if (count($list) == 0) { ?>
    <tr><td colspan=4 align=center height=50>게시물이 없습니다.</td></tr>
<? } else { ?>
    <script language="javascript">
    var roll_height_<?=$uni?> = <?=$box_height?>;
    var total_area_<?=$uni?> = 0;
    var wait_flag_<?=$uni?> = true;
    var bMouseOver_<?=$uni?> = 1;
    var roll_speed_<?=$uni?> = 3;
    var waitingtime_<?=$uni?> = 3000;
    var s_tmp_<?=$uni?> = 0;
    var s_amount_<?=$uni?> = <?=(int)$height?>;
    var roll_text_<?=$uni?> = new Array();
    var startPanel_<?=$uni?> = 0;
    var n_panel_<?=$uni?> = 0;
    var i_<?=$uni?> = 0;
    function start_roll_<?=$uni?>()
    {
        i_<?=$uni?> = 0;
        for (i_<?=$uni?> in roll_text_<?=$uni?>)
            n_panel_<?=$uni?>++;
        n_panel_<?=$uni?> = n_panel_<?=$uni?> -1 ;
        startPanel_<?=$uni?> = Math.round(Math.random()*n_panel_<?=$uni?>);
        if(startPanel_<?=$uni?> == 0) {
            i_<?=$uni?> = 0;
            for (i_<?=$uni?> in roll_text_<?=$uni?>)
                insert_area_<?=$uni?>(total_area_<?=$uni?>, total_area_<?=$uni?>++);
        } else if(startPanel_<?=$uni?> == n_panel_<?=$uni?>) {
            insert_area_<?=$uni?>(startPanel_<?=$uni?>, total_area_<?=$uni?>);
            total_area_<?=$uni?>++;
            for (i_<?=$uni?>=0; i_<?=$uni?><startPanel_<?=$uni?>; i_<?=$uni?>++) {
                insert_area_<?=$uni?>(i_<?=$uni?>, total_area_<?=$uni?>);
                total_area_<?=$uni?>++;
            }
        } else if((startPanel_<?=$uni?> > 0) || (startPanel_<?=$uni?> < n_panel_<?=$uni?>)) {
            insert_area_<?=$uni?>(startPanel_<?=$uni?>, total_area_<?=$uni?>);
            total_area_<?=$uni?>++;
            for (i_<?=$uni?>=startPanel_<?=$uni?>+1; i_<?=$uni?><=n_panel_<?=$uni?>; i_<?=$uni?>++) {
                insert_area_<?=$uni?>(i_<?=$uni?>, total_area_<?=$uni?>);
                total_area_<?=$uni?>++;
            }
            for (i_<?=$uni?>=0; i_<?=$uni?><startPanel_<?=$uni?>; i_<?=$uni?>++) {
                insert_area_<?=$uni?>(i_<?=$uni?>, total_area_<?=$uni?>);
                total_area_<?=$uni?>++;
            }
        }
     
        if ( navigator.appName == "Microsoft Internet Explorer" ) {
            if ( navigator.appVersion.indexOf ( "MSIE 4" ) > -1 )
            return ;
        }
        window.setTimeout("rolling_<?=$uni?>()",waitingtime_<?=$uni?>);
    }
    function rolling_<?=$uni?>()
    {
        if (bMouseOver_<?=$uni?> && wait_flag_<?=$uni?>) {
            for (i_<?=$uni?>=0;i_<?=$uni?><total_area_<?=$uni?>;i_<?=$uni?>++) {
                tmp_<?=$uni?> = document.getElementById('scroll_area_<?=$uni?>'+i_<?=$uni?>).style;
                tmp_<?=$uni?>.top = parseInt(tmp_<?=$uni?>.top)-roll_speed_<?=$uni?>;
               
                if (parseInt(tmp_<?=$uni?>.top) <= -roll_height_<?=$uni?>) {
                    tmp_<?=$uni?>.top = roll_height_<?=$uni?>*(total_area_<?=$uni?>-1);
                }
               
                if (s_tmp_<?=$uni?>++ > (s_amount_<?=$uni?>-1)*roll_text_<?=$uni?>.length) {
                    wait_flag_<?=$uni?>=false;
                    window.setTimeout("wait_flag_<?=$uni?>=true;s_tmp_<?=$uni?>=0;",waitingtime_<?=$uni?>);
                }
            }
        }
        window.setTimeout("rolling_<?=$uni?>()", 1);
    }
    function insert_area_<?=$uni?>(idx_<?=$uni?>, n_<?=$uni?>)
    {
        document.write('<div style="left: 0px; width: 100%; position: absolute; top: '+(roll_height_<?=$uni?>*n_<?=$uni?>)+'px" id="scroll_area_<?=$uni?>'+n_<?=$uni?>+'">\n'+roll_text_<?=$uni?>[idx_<?=$uni?>]+'\n</div>\n');
    }
    <?
    unset($roll_text);
    for ($i=0; $i<count($list); $i++) {
        $href = "<a href='./?doc=$cart_dir/item.php&it_id=$row[it_id]' class=item>";
        $k = (int)($i / $line_mod);
        $roll_text[$k] .= "<div style=\"height:{$height}px; padding-top:5px;\">";
        $roll_text[$k] .= "<a href=\"{$list[$i][href]}\">";
        $roll_text[$k] .= "<img src=\"{$latest_skin_path}/img/latest_icon.gif\" align=absmiddle border=0>  ";
        $roll_text[$k] .= $list[$i][subject];
        $roll_text[$k] .= "</a>";
        if ($list[$i][comment_cnt])
            $roll_text[$k] .= " <a href=\"{$list[$i][comment_href]}\">{$list[$i][comment_cnt]}</a>";
        $roll_text[$k] .= "</div>";
    }
    for ($i=0; $i<=$k; $i++) {
        echo "roll_text_{$uni}[$i] = '{$roll_text[$i]}';\n";
    }
    ?>
    </script>
    <div style="left: 0px; width: 100%; position: relative; top: 0px; height: <?=$box_height?>px; overflow:hidden;" onMouseover="bMouseOver_<?=$uni?>=0" onMouseout="bMouseOver_<?=$uni?>=1" id="latest_scroll_<?=$uni?>">
    <script language='javascript'>
    var no_script_flag_<?=$uni?> = false ;
    if ( navigator.appName == "Microsoft Internet Explorer" ) {
        if ( navigator.appVersion.indexOf ( "MSIE 4" ) > -1 ) {
            document.write ( roll_text_<?=$uni?>[0] ) ;
            no_script_flag_<?=$uni?> = true ;
        }
    }
    if ( no_script_flag_<?=$uni?> == false )
        start_roll_<?=$uni?>();
    </script>
    </div>         
<? } ?>
</td></tr>
<tr><td colspan=4 bgcolor=#EBEBEB height=1></td></tr>
</table>
 
 
그룹 게시판
스크롤 되는 최신글(개별게시판)
 
위의 표같이 메인화면에 추출할려고 하는데 문제는 스크롤 되는 최신글이 개별게시판이 아닌 그룹으로 추출되는것 같습니다.
메인 상단에 include_once("$g4[path]/lib/userfunction.lib.php"); 이것 때문인 것 같은데 해결할 방법을 못찾겠습니다.
함수나 변수가 겹쳐서 그런것인가요?
고수님들 좀 도와 주십시요^^
해결 방법이 없을까요?
 
 
  • 복사

댓글 전체

관리자님의 스크롤 최신글의 사용법은

// 스킨, 게시판아이디, 출력라인, 글자수, "몇개라인,라인높이"
// latest($skin_dir="", $bo_table, $rows=10, $subject_len=40, $options="")

이게 사용법인데요..

그룹 최신글은 사용법이

// latest_group($skin_dir="", $gr_id, $rows=10, $subject_len=40, $options="")


이렇게 되기 때문에 충돌이 나지는 않을 듯 하구요.


latest_group 과 latest 를 바꾸어 사용하신게 아닌지 모르겠네요..
마시마님 답변 감사합니다.
그런데 그런것이 아닙니다.
마시마님이 생각한것처름 바꿔쓴것이 아닙니다.^^
메인화면에 undefined 가 계속 올러오길래 lib/userfunction.lib.php를 불러오는 그룹최신글<?= latest_group("view_gallery", "gallery", 40, 25)?>을 지우니 스크롤최신글이 제대로 동작을 하는겁니다.^^
마시마님 관심 가져 줘서 감사합니다.
이글을 보시는 다른분들 오해가 있으실까봐 알려드립니다.
위에 올린 소스가 문제가 있는것이 아니라 view_gallery의 자바스크립트에서 문제가 있는것 같습니다.
© SIRSOFT
현재 페이지 제일 처음으로