Kohana 3 :: stylesheets and scriptfiles

Helper


<?php defined('SYSPATH') or die('No direct script access.');
// kohana tutorials :: kohanaframework.blogspot.comclass javascript {
    private static $files = array();

    public static function add($file)
    {
        self::$files[] = $file;
    }

    public static function get()
    {
        return self::$files;
    }
}

Controller

class Controller_Example extends Controller_Template {

    public function before()
    {
        
        javascript::add('js/jquery.js');
        javascript::add('js/jquery-ui.js');
        
    }
}

Views


<html>
    <head>
        <?php foreach(javascript::get() as $javascript ?>
        <script type="text/javascript" src="<?= $javascript ?>"></script> 
        <?php endforeach; ?>
    </head>
</html>

0 comments:

Post a Comment