최근게시물 순서변경 정보
최근게시물 순서변경본문
최근게시물을 이용하여 제품리스트를 보여주고자 합니다.
이때 먼저 등록한 제품이 제일 상단에 보여지고 나중에 등록한 제품이 제일 아래부분에 보여지도록 하고싶습니다.
최근게시물은 기본적으로 최근에 작성한 글이 상단에 보여지므로 이 순서를 변경하는 방법을 몇일전에 여쭤보았고 운이님께서 적당한 답을 주셨습니다.
헌데 제가 사용하는 최근게시물 스킨은 겔러리 형식의 최근게시물이다보니 먼저번에 운이님이 알려주신 답변이 적용되지 않아서 소스를 올려보겠습니다.
허접한 질문이더라도 이해해 주시고 도와주세요~~
===== 먼저번 운이님께서 알려주신 답변 =============================
latest 스킨의 내용중
<? for ($i=0; $i<count($list); $i++) { ?> 이부분을 찾아
<? for ($i=count($list)-1; $i>=0; $i--) { ?> 로 바꿔주면 됩니다.
============== 소스 ==============================================
<?
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
list($height, $row_cnt) = explode(",", $options);
$all_cnt = 0;
?>
$all_cnt = 0;
?>
<!-- <?=$board[bo_subject]?> (<?=$board[bo_table]?>) 최신글 -->
<table width='95%'>
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<?
for ($i=0; $i<count($list)/$row_cnt; $i++)
{
if ($i > 0)
echo '<td width=20> </td>';
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<?
for ($i=0; $i<count($list)/$row_cnt; $i++)
{
if ($i > 0)
echo '<td width=20> </td>';
$title = get_text($list[$all_cnt][wr_subject]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
if (!file_exists($img) || !$list[$all_cnt][file][0][file])
$img = "$latest_skin_path/img/no_image.gif";
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
echo <<<HEREDOC
<td width='<?=$subject_len?>' valign='top'>
<table width='<?=$subject_len?>' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='<?=$subject_len?>' height='5'></td>
</tr>
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
if (!file_exists($img) || !$list[$all_cnt][file][0][file])
$img = "$latest_skin_path/img/no_image.gif";
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
echo <<<HEREDOC
<td width='<?=$subject_len?>' valign='top'>
<table width='<?=$subject_len?>' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='<?=$subject_len?>' height='5'></td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='<?=$height?>'>
<div style='width:<?=$subject_len?>px;height:<?=$height?>px;border:1px solid #CCCCCC;padding:3px'>
<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'><img src='{$img}' width='$subject_len' height='$height' border='0' align='absmiddle' title='$title'></a>
</div>
</td>
<td width='<?=$subject_len?>' height='5'></td>
<td width='<?=$subject_len?>' height='20'> <a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}&sst=wr_datetime&sod=asc'>{$list[$all_cnt][subject]}</a></td>
</tr>
<td width='<?=$subject_len?>' height='<?=$height?>'>
<div style='width:<?=$subject_len?>px;height:<?=$height?>px;border:1px solid #CCCCCC;padding:3px'>
<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'><img src='{$img}' width='$subject_len' height='$height' border='0' align='absmiddle' title='$title'></a>
</div>
</td>
<td width='<?=$subject_len?>' height='5'></td>
<td width='<?=$subject_len?>' height='20'> <a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}&sst=wr_datetime&sod=asc'>{$list[$all_cnt][subject]}</a></td>
</tr>
</table>
</td>
HEREDOC;
$all_cnt++;
}
?>
</tr>
<? } ?>
<? if (count($list) == 0) { ?>
<tr><td colspan=2 align='center' height=25>게시물이 없습니다.</td></tr>
<? } ?>
</table>
<tr><td colspan=2 align='center' height=25>게시물이 없습니다.</td></tr>
<? } ?>
</table>
댓글 전체
for ($i=0; $i<count($list)/$row_cnt; $i++) 이부분을
for ($i=count($list)/$row_cnt;$i>=0; $i--) 로 하고
$all_cnt를 모두 $i 로 변경하세요
그럼 될겁니다.
for ($i=count($list)/$row_cnt;$i>=0; $i--) 로 하고
$all_cnt를 모두 $i 로 변경하세요
그럼 될겁니다.
몇일째 해봤는데 잘 안되네요 제가 많이 무식한것 같네요