📜 ⬆️ ⬇️

Asset helper in CodeIgniter

Using this thing is damn convenient to manage materials (asset) of the site, which are static files that are not related to the framework: CSS-styles, JavaScript-files, pictures. Create an assets folder in the project root, create the following folders in this folder:



assets /
- css /
- image /
- js /
- modules /
- modulename /
- css /
- image /
- js /
- modulename2 /
- css /
- image /
- js /

')
Asset Helper helps to generate the necessary code to insert materials into an HTML document:

$ this-> load-> helper ('asset');

// Load the CSS file
css_asset ('filename.css');

// Load (generates code) image filename.jpg from module
// modulename (subfolder in the assets folder).
// In addition, it takes the third parameter of the array of attributes of the tag IMG
image_asset ('filename.jpg', 'modulename', array ('alt' => 'Image name', 'width' => 50));

// Generate link (not code) to javascript file in modulename module
js_asset_url ('filename.js', 'modulename');


Naturally, all helper functions can (and should) be used in views.

Source: https://habr.com/ru/post/27417/


All Articles