Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 17 revisions

The Asset Helper is designed to make keeping track of those pesky JavaScript, image, CSS and flash files just that little bit easier. We all know that its a bad plan to keep your files in your system/ folder, so where else can they go?

By using Asset Helper they can be easily stored on the site in a seperate folder and will also give you a firm structure to keep your files all organised logically.

[b]Folder Structure[/b]

[quote]assets/ -- css/ -- image/ -- js/ -- modules/ ---- modulename/ ------ css/ ------ image/ ------ js/ ---- modulename2/ ------ css/ ------ image/ ------ js/ [/quote]

This folder structure should make sense to you. Basically you have your generic files (logos, general stylesheets, banners, buttons, etc) and you have page specific ones, such as sub-page backgrounds and section headers. These go in a module in the asset folder named whatever you want (makes sense to give it the same name as your controller though eh?).

[b]Useage[/b] [code]$this->load->helper('asset');

// Load a css file from the main asset css folder css_asset('filename.css');

// Load a image from the modulename. Images has a 3rd optional param for attributes image_asset('filename.jpg', 'modulename', array('alt'=>'Image name!', 'width'=>50));

// Load a javascript from the main folder, BUT we only want the url and not the entire HTML tag. js_asset_url('filename.js', 'modulename');

// Want something other than a image, css or js? // The third param here tells us what the type is, typename being the folder its kept in. other_asset_url('banner.swf', '', 'flash'); [/code]

Download File: File:asset_helper.zip

Category:Contributions::Helpers::Assets Category:Assets

Clone this wiki locally