CI 코드

제목 [CI2/CI3] Straight-layout
글쓴이 조현 작성시각 2018/04/20 15:56:51
댓글 : 0 추천 : 1 스크랩 : 0 조회수 : 17073   RSS
조현

Apply CI version

Method

$this->load->cache() // browser cache Default : $time=60, $Etag=NULL
$this->load->css('any.css'); // chainning
$this->load->js('any.js');  // chainning
$this->load->view('any', []);   // CI3 default
$this->load->view('any', [], TRUE);   // CI3 default, non chain
$this->load->cache()->css()->js()->view()->view()->css()->js()->view();    // usage

Config

$config['modules'] = ['layout'];
$config['asset_controller'] = 'asset';
$config['asset_hashkey'] = 'md5';
$config['asset_nocache_uri'] = TRUE;   // TRUE : /asset/css/style.css?_=abc...1234, FALSE : /asset/cas/style.css
$config['asset_combine'] = TRUE;    // TRUE|FALSE css, js combine, TRUE: use cache if possible or query
$config['asset_minify_js'] = TRUE;  // require composer minify lib
$config['asset_minify_css'] = TRUE; // require composer minify lib

$config['adapter'] =  ['adapter' => 'dummy', 'backup' => 'file'];  // CI cache lib, default dummy
$config['ttl'] = 2592000;	// 30 day

$config['view_skin'] = '_skin';
$config['view_layout'] = '_layout';
$config['view_minify'] = TRUE;

Ex Controller

Class Welcome extends MY_Controller
{
    public function index() {
        $this->load
            ->cache(5)
            ->css('https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css')
            ->js([
                ['src'=>'https://code.jquery.com/jquery-3.2.1.slim.min.js', 'integrity'=>'sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN','crossorigin'=>'anonymous'],
                'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js',
            ])->js([
                'src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" crossorigin="anonymous"'
            ])->view('welcome_head')
            ->view('welcome_message')
            ->view('welcome_foot');
    }
}

Ex Output

<html>
<head>
    ...
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" />
    <link rel='stylesheet' type='text/css' href='/asset/css/_layout.css' />
    <link rel='stylesheet' type='text/css' href='/asset/css/_skin.css' />
    <link rel='stylesheet' type='text/css' href='/asset/css/welcome_head.css' />
    <link rel='stylesheet' type='text/css' href='/asset/css/welcome_message.css' />
</head>
<body>
    
    <_layout.php>
        <_skin.php>
            <welcome_head.php>
            <welcome_message.php>
            <welcome_foot.php>
        </_skin.php>
    </_layout.php>

    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
    <script type='text/javascript' src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" crossorigin="anonymous"></script>
    <script type='text/javascript' src='/asset/js/_layout.js'></script>
    <script type='text/javascript' src='/asset/js/_skin.js'></script>
    <script type='text/javascript' src='/asset/js/welcome_message.js'></script>
    <script type='text/javascript' src='/asset/js/welcome_foot.js'></script>
</body>
</html>

 

태그 minify,layout,straight
관련링크 https://github.com/uncaose/straight-ci-layout/tags
 다음글 자작 JWTAuth 라이브러리 (1)
 이전글 [CI2/CI3] 간단한 코드의 Alert 헬퍼입니다. (1)

댓글

없음