sosososo

목록 순서 쉽게 바꾸기

안녕하세요.

 

졸음운전 뒷빵 사고로 3중추돌.... 차는 폐차... 현재 병원 입원중인데,  일하고 있네요 ㅠㅠ

 

 

목록 정렬때문에 불편한적 많으실거에요~~

공지사항 아래  숫자 순서대로 정렬되며,  미지정은 기존과 동일

 

 

숫자 변경 후 새로고침만 하시면 정렬 완료!!
1794962123_1766221382.8634.png

/bbs/ajax_num_list.php ( 파일생성 / 경로및 파일명은 알아서 하셔요.)

 

<?php

include_once('./_common.php');

 

if (!$is_admin) {

    echo 'no_admin';

    exit;

}

 

$wr_id = (int)$_POST['wr_id'];

$wr_9  = trim($_POST['wr_9']);

 

if (!$wr_id) {

    echo 'no_wr_id';

    exit;

}

 

$bo_table = preg_replace('/[^a-z0-9_]/i', '', $_POST['bo_table']);

if (!$bo_table) {

    echo 'no_table';

    exit;

}

 

$write_table = $g5['write_prefix'] . $bo_table;

 

sql_query("

    UPDATE {$write_table}

    SET wr_9 = '".sql_real_escape_string($wr_9)."'

    WHERE wr_id = '{$wr_id}'

");

 

echo 'ok';


------------------------------------------------------------- 

저는 여분필드9 ( wr_9) 을 사용 했습니다.

---------------------------------------------------------------------------

 

/bbs/list.php

 

// 정렬

// 인덱스 필드가 아니면 정렬에 사용하지 않음

//if (!$sst || ($sst && !(strstr($sst, 'wr_id') || strstr($sst, "wr_datetime")))) {

if (!$sst) {

    if ($board['bo_sort_field']) {

        $sst = $board['bo_sort_field'];

    } else {

        $sst  = "wr_num, wr_reply";

        $sod = "";

    }

} else {

    $sst = preg_match("/^(wr_datetime|wr_hit|wr_good|wr_nogood)$/i", $sst) ? $sst : "";

}

 

// ===============================

// wr_9 관리자 지정 정렬 (0201 게시판 전용)

// ===============================

if ($bo_table === '0201') {

 

    $sql_order = "

        ORDER BY

            (wr_9 IS NULL OR wr_9 = '') ASC,

            wr_9 ASC,

            wr_datetime DESC

    ";

 

} else {

 

    // 기본 그누보드 정렬

    $sql_order = " ORDER BY {$sst} {$sod} ";

}



 

// if(!$sst)

//     $sst  = "wr_num, wr_reply";

 

// if ($sst) {

//     $sql_order = " order by {$sst} {$sod} ";

// }

 

------------------------------------------------------------

 

 

list.skin.php

 

 

<div class="gall_box"> 
 

<div class="admin-sort-box">

    <input type="number"

           class="admin-sort-input"

           data-wr-id="<?php echo $list[$i]['wr_id']; ?>"

           value="<?php echo $list[$i]['wr_9']; ?>"

           placeholder="정렬"

           style="width:60px; text-align:center;">

</div>

 

 

 

스킨 맨 아래쪽에 

 

<script>

document.querySelectorAll('.admin-sort-input').forEach(input => {

    input.addEventListener('change', function () {

        const wrId = this.dataset.wrId;

        const value = this.value;

 

        fetch('<?php echo G5_BBS_URL; ?>/ajax_num_list.php', {

            method: 'POST',

            headers: {'Content-Type': 'application/x-www-form-urlencoded'},

            body:

                'bo_table=<?php echo $bo_table; ?>' +

                '&wr_id=' + wrId +

                '&wr_9=' + encodeURIComponent(value)

        })

        .then(res => res.text())

        .then(res => {

            if (res !== 'ok') {

                alert('정렬 저장 실패: ' + res);

            }

        });

    });

});

</script>

 

 

-------------------------------------------------------------

허접하지만 사용시 너무 편하네요~~ ㅎ

 

능력자 분께서 더 좋은 업그레이드 버전 기대 해 볼게요 ^^

 

 

 

질문은 받지 않겠습니다.

|

댓글 7개

추천합니다^^

T_T.. 쾌유를 빕니다. 참 차사고는 정말..

@techstar 감사합니다.

css 

.admin-sort-box {

  position: absolute;

  top: 10px;

  right: 32px;

  z-index: 20;

  background: rgba(255,255,255,0.9);

  padding: 4px;

  border-radius: 4px;

}

 

.admin-sort-input {

  font-size: 12px;

  height: 24px;

}

 

수고많으셨습니다.

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

그누보드5 팁자료실

+
제목 글쓴이 날짜 조회
4일 전 조회 88
1주 전 조회 186
1주 전 조회 228
2주 전 조회 286
2주 전 조회 299
2주 전 조회 266
3주 전 조회 424
3주 전 조회 276
3주 전 조회 370
4주 전 조회 323
1개월 전 조회 435
1개월 전 조회 445
1개월 전 조회 342
1개월 전 조회 525
1개월 전 조회 499
1개월 전 조회 461
1개월 전 조회 446
1개월 전 조회 512
1개월 전 조회 435
1개월 전 조회 427
2개월 전 조회 590
2개월 전 조회 438
2개월 전 조회 635
2개월 전 조회 502
2개월 전 조회 564
2개월 전 조회 559
2개월 전 조회 471
2개월 전 조회 512
2개월 전 조회 398
2개월 전 조회 495