Asset Helper
The Asset Helper file contains methods that assist in working with assets, namely images, css files, javascript files and favicons.
Loading this Helper
This helper is loaded using the following code:
loadHelper "asset"
Note: To use this helper you should put your assets into a folder called "assets" at your root. You can change this path in your application/config/config.irev file. This helper assumes that your image folder is called "img", that your CSS folder is called "css" and that your Javascript folder is called "js". If you don't like that, you can change the corresponing variables at the top of the helper script.
The following methods are available:
cssAsset(tAsset, tAttributes, tModule)
Generates a css asset location html code.
The first parameter is the name of your CSS file. The second optional parameter is an array of attributes and the third optional parameter a folder name where you store assets for the current page if you like to organize assets for different pages in separate folders. This folder should be located in a "modules" folder, which is located in the "assets" folder"
Here is an example for the header section in your view file:
<? return cssAsset("myCSS.css") ?>
imageAsset(tAsset, tAttributes, tModule)
Generates image asset location html code.
The first parameter is the name of your image file. The second optional parameter is an array of attributes and the third optional parameter a folder name where you store assets for the current page if you like to organize assets for different pages in separate folders. This folder should be located in a "modules" folder, which is located in the "assets" folder"
Example:
put "pics" into tArray["class"]
put "My Portrait" into tArray["alt"]
put imageAsset("myPic.jpg", tArray, "aboutMe") into gData["myPic"]
"aboutMe" would be a folder in your "assets" folder.
jsAsset(tAsset, tModule)
Generates JavaScript asset location html code.
The first parameter is the name of your Javascript file. The second optional parameter is a folder name where you store assets for the current page if you like to organize assets for different pages in separate folders. This folder should be located in a "modules" folder, which is located in the "assets" folder"
Here is an example for your view file:
<? return jsAsset("myScript.js") ?>
addFavicon()
Generates a link tag using the base url that points to favicon.
Use this function, if your favicon is not located at your root.
Here is an example for your view file:
<? return addFavicon() ?>