The Assets class provides some functions for displaying assets (cascading style sheets, javascript, images).
Here is a list of available public methods for this class:
This method render automatically valid html code for css, js or image files in condition of given file extension.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$path | string | Usually you should use the framework constants like CSS_PATH, JS_PATH, or IMAGE_PATH depending of what kind of asset wich should be displayed. | ||
$file | string | Filename of asset. | ||
$css_classname | string | false | Name of css class. This only will be used by images! | |
$document_type | string | HTML5 | Document type: HTML4, XHTML or HTML5 are supported. |
Assets::forge(CSS_PATH, 'styles.css'); Assets::forge(JS_PATH, 'functions.js'); Assets::forge(IMAGE_PATH, 'test.png', 'myClass', 'XHTML'); // Output: <link rel="stylesheet" type="text/css" href="/assets/css/styles.css?1401180139"> <script type="text/javascript" src="/assets/js/functions.js?1401180139"></script> <img src="/assets/images/test.png" class="myClass"/>
This method display valid html code for given css file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$path | string | Usually you should use the framework css path constant CSS_PATH. | ||
$file | string | CSS filename | ||
$document_type | string | HTML5 | Document type: HTML4, XHTML or HTML5 are supported. |
Assets::css(CSS_PATH, 'styles.css'); // Output: <link rel="stylesheet" type="text/css" href="/assets/css/styles.css?1401180139">
This method display valid html code for given javascript file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$path | string | Usually you should use the framework css path constant JS_PATH. | ||
$file | string | JS filename. | ||
$document_type | string | HTML5 | Document type: HTML4, XHTML or HTML5 are supported. |
Assets::js(JS_PATH, 'functions.js'); // Output: <script type="text/javascript" src="/assets/js/functions.js?1401180139"></script>
This method display valid html code for given image file.
Static | Yes | |||
Parameters | Parameter | Type | Default | Description |
$path | string | Usually you should use the framework image path constant IMAGE_PATH. | ||
$file | string | image filename. | ||
$css_classname | string | false | Name of css class. This only will be used by images! | |
$document_type | string | HTML5 | Document type: HTML4, XHTML or HTML5 are supported. |
Assets::forge(IMAGE_PATH, 'test.png'); // Output: <img src="/assets/images/test.png">