2026, 새로운 도약을 시작합니다.

add_stylesheet와 add_javascript의 방법에 파일수정시간으로 버전명 달기

https://sir.kr/g5_tip/18640 해당 팁의 css, js 파일의 수정 시간을 verison에 수정하는 기능을 그누보드에서 제공하는 add_stylesheet와 add_javascript의 방법을 수정해서 올려드립니다.

common.lib.php파일을 열어서 아래 부분을 찾아서 변경해주시면 되겠습니다.

function add_stylesheet($stylesheet, $order=0)

{

    global $html_process;

    $patten = "/<link[^>]*href=[\"']?([^>\"']+)[\"']?[^>]*>/i";

    preg_match_all($patten, $stylesheet, $match);

    $file = $match[1][0];

    if(strpos($file, G5_URL) !== false) {

        $file_location = str_replace(G5_URL, '', $file);

        $file_real_location = G5_PATH.'/'.$file_location;

        if (file_exists($file_real_location)) {

            $file_ver = "?ver=".date( 'YmdHis', filemtime($file_real_location));

        }

        $stylesheet = str_replace($file, $file.$file_ver, stripslashes($stylesheet));

    }

    if(trim($stylesheet) && method_exists($html_process, 'merge_stylesheet'))

        $html_process->merge_stylesheet($stylesheet, $order);

}

function add_javascript($javascript, $order=0)

{

    global $html_process;

    $patten = "/<script[^>]*src=[\"']?([^>\"']+)[\"']?[^>]*>/i";

    preg_match_all($patten, $javascript, $match);

    $file = $match[1][0];

    if(strpos($file, G5_URL) !== false) {

        $file_location = str_replace(G5_URL, '', $file);

        $file_real_location = G5_PATH.'/'.$file_location;

        if (file_exists($file_real_location)) {

            $file_ver = "?ver=".date( 'YmdHis', filemtime($file_real_location));

        }

        $javascript = str_replace($file, $file.$file_ver, stripslashes($javascript));

    }

    if(trim($javascript) && method_exists($html_process, 'merge_javascript'))

        $html_process->merge_javascript($javascript, $order);

}

|

댓글 2개

유용한 정보 감사합니다.
감사합니다. ^^

댓글 작성

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

로그인하기

그누보드5 팁자료실

번호 제목 글쓴이 날짜 조회
공지 3년 전 조회 4,598
2741 3일 전 조회 111
2740 4일 전 조회 103
2739 1주 전 조회 209
2738 1주 전 조회 217
2737 1주 전 조회 181
2736 1주 전 조회 280
2735 3주 전 조회 281
2734 3주 전 조회 263
2733 1개월 전 조회 265
2732 1개월 전 조회 301
2731 1개월 전 조회 267
2730 1개월 전 조회 226
2729 1개월 전 조회 356
2728 1개월 전 조회 245
2727 1개월 전 조회 422
2726 1개월 전 조회 256
2725 1개월 전 조회 330
2724 1개월 전 조회 358
2723 1개월 전 조회 267
2722 1개월 전 조회 300
2721 1개월 전 조회 211
2720 2개월 전 조회 304
2719 2개월 전 조회 307
2718 2개월 전 조회 202
2717 2개월 전 조회 336
2716 2개월 전 조회 202
2715 2개월 전 조회 311
2714 2개월 전 조회 273
2713 2개월 전 조회 376
2712 2개월 전 조회 289
🐛 버그신고