Functions available inside Templates
List of all the Functions that can be used inside the Templates.
$theme_view($name, $data = null)
This function is Only Availble inside Templates. It is used to load a Template from the Current Theme Directory. You can use this function to load Relative Templates. The $ is Required.
Usage:
Arguments:
Argument | Description | Required | Default |
---|---|---|---|
$name | Relative Path to Template. | TRUE | undefined |
$data | Array of Variables. | FALSE | null - Will use the Data from the Greater Context by Default |
info
Greater Context
refers to the Data that has been passed to Core Templates. The data that is available inside Core Templates will always be available to the templates included inside the Core Templates.
$assets($path)
This function is Only Availble inside Templates. It is used to load Assets from the assets
directory in the Current Theme Directory. You can use this function to load Relative Assets inside your Templates. The $ is Required.
Usage:
Arguments:
Argument | Description | Required | Default |
---|---|---|---|
$path | Relative Path to Asset. | TRUE | undefined |
info
The $assets()
function will only return assets placed inside the assets
folder.
You must follow the Proper structure to develop your themes.
Global Functions
These functions are not limited only to templates, You can use these functions anywhere. They do not require the $ sign as these are normal PHP functions.
public_assets($path)
This function is used to Assets from the public
directory in your Website Root Directory. You can use this function to load Public Assets that are available to All Themes & All Templates.
Usage:
Arguments:
Argument | Description | Required | Default |
---|---|---|---|
$path | Path to Asset inside public Directory. | TRUE | undefined |
info
This function is similar to $assets()
, but It loads assets from the public
directory from your Website's Root whereas $assets()
loads the assets from the assets
folder of the Current Theme Directory.
anchor_to($path)
This function is used to print a URL to a Page of your Website.
Usage:
Argument | Description | Required | Default |
---|---|---|---|
$path | The URI of the Page. (Permalink / Slug) | TRUE | undefined |
esc($str, $html)
This function is used to escape HTML before printing. Set the 2nd Arugment to true for Decoding HTML entities (Useful for Printing JS, and Other HTML Tags)
Usage:
Argument | Description | Required | Default |
---|---|---|---|
$str | The value to escape | TRUE | undefined |
$html | Set this to true for printing HTML tags | FALSE | false |
info
This list only includes the most commonly used functions for Theme Development.
There are a lot of other functions. Refer to root/application/helpers/main_helper.php
to view a List & Definitions of all available Global Functions.