Fuel Helper
Contains FUEL specific functions. This helper is automatically loaded with the autoload config.
Function Reference [+]
fuel_instance()
Returns the instance of the FUEL object.
Returns
object
FUEL()
Returns the instance of the FUEL object just like fuel_instance but with a similar syntax to the CI() function which returns the CI object.
Returns
object
fuel_block($params, [$vars=array()], ['$check_db'=TRUE], ['$scope'=NULL])
Allows you to load a view and pass data to it. The params parameter can either be string value (in which case it will assume it is the name of the block view file) or an associative array that can have the following values:
- view - the name of the view block file. Also can be the first parameter of the method
- vars: an array of variables to pass to the block. Also can be the second parameter of the method.
- view_string - a string variable that represents the block
- model - the name of a model to automatically load for the block
- find - the name of the find method to run on the loaded model
- select - select parameters to run for the find method
- where - where parameters to run for the find method
- order - the order the find method should return
- limit - the limit number of results to be returned by the find method
- offset - the find results returned offset value
- return_method: the return method the find query should use
- assoc_key: the column name to be used as the associative key in the find method
- data: the data values to be passed to the block. This variable get's automatically set if you specify the model and find method
- editable: css class styles to apply to menu items... can be a nested array
- parse: determines whether to parse the contents of the block. The default is set to 'auto'
- cache: determines whether to cache the block. Default is false
- mode: explicitly will look in either the CMS or the views/_blocks folder
- module: the name of the module to look in for the block
- language: the language version to use for the block. Must be a value specified found in the 'languages' options in the FUEL configuration
- use_default: determines whether to find a non-language specified version of a block with the same name if the specified language version is not available in the CMS
Returns
string
Parameters
(array) $params (array) $vars (boolean) $check_db (string) $scope
fuel_nav([$params=array()])
Creates a menu structure. The params parameter is an array of options to be used with the Menu class. If FUEL's configuration mode is set to either auto or cms, then it will first look for data from the FUEL navigation module. Otherwise it will by default look for the file views/_variables/nav.php (you can change the name of the file it looks for in the file parameter passed). That file should contain an array of menu information (see Menu class for more information on the required data structure). The parameter values are very similar to the Menu class, with a few additions shown below:
- items - the navigation items to use. By default, this is empty and will look for the nav.php file or the records in the Navigation module
- file - the name of the file containing the navigation information
- var - the variable name in the file to use
- parent - the parent id you would like to start rendering from. This is either the database ID or the nav array key of the menu item
- root - the equivalent to the root_value attribute in the Menu class. It states what the root value of the menu structure should be. Normally you don't need to worry about this
- group_id - the group ID in the database to use. The default is 1. Only applies to navigation items saved in the admin
- exclude - nav items to exclude from the menu. Can be an array or a regular expression string
- return_normalized - returns the raw normalized array that gets used to generate the menu
- render_type: options are basic, breadcrumb, page_title, collapsible, delimited, array. Default is 'basic'
- active_class: the active css class. Default is 'active'
- active: the active menu item
- styles: css class styles to apply to menu items... can be a nested array
- first_class: the css class for the first menu item. Default is first
- last_class: the css class for the last menu item. Default is last
- depth: the depth of the menu to render at
- use_titles: use the title attribute in the links. Default is FALSE
- container_tag: the html tag for the container of a set of menu items. Default is ul
- container_tag_attrs: html attributes for the container tag
- container_tag_id: html container id
- container_tag_class: html container class
- subcontainer_tag_class: an array of css classes to apply to subcontainers
- cascade_selected: cascade the selected items. Default is TRUE
- include_hidden: include menu items with the hidden attribute. Default is FALSE
- item_tag: the html list item element. Default is 'li'
- item_id_prefix: the prefix to the item id
- item_id_key: either id or location. Default is 'id'
- use_nav_key: determines whether to use the nav_key or the location for the active state. Default is "AUTO"
- pre_render_func: function to apply to menu labels before rendering
- delimiter: the html element between the links
- arrow_class: the class for the arrows used in breadcrumb type menus
- display_current: determines whether to display the current active breadcrumb item
- home_link: the root home link
- append: appends additional menu items to those items already set (e.g. from the $nav array or from the navigation module). Good to use on dynamic pages where you need to dynamically set a navigation item for a page
- order: the order to display... for page_title ONLY
- language: select the appropriate language
- include_default_language: will merge in the default language with the results. Default is FALSE
- language_default_group: the default group to be used when including a default language. Default is FALSE
For more information see the Menu class.
Returns
string
Parameters
(array) $params
fuel_page($location, [$vars=array()], [$params=array()])
Generates a page using the Fuel_page class.
Returns
string
Parameters
(array) $location (array) $vars
fuel_form('$fields', [$values=array()], [$params=array()])
Creates a form using form builder.
Returns
string
Parameters
(mixed) $fields (array) $values (array) $params
fuel_model('$module', [$params=array()], [$where=array()])
Loads a module model and creates a variable in the view that you can use to merge data. The params parameter is an associative array that can have the following values:
- find - the find method to use on the module model. Options are "one", "key", "all" or any method name on the model that begins with "find_" (excluding "find_" from the value)
- select - the select condition to filter the results of the find query
- where - the where condition to be used in the find query
- order - order the data results and sort them
- limit - limit the number of data results returned
- offset - offset the data results
- return_method - the return method to use which can be an object or an array
- assoc_key - the field to be used as an associative key for the data results
- var - the variable name to assign the data returned from the module model query
- module - specifies the module folder name to find the model
Returns
mixed
Parameters
(string) $module (mixed) $params (mixed) $where
fuel_set_var('$key', ['$val'=NULL])
Sets a variable for all views to use (including layouts) no matter what view it is declared in. Using fuel_set_var in a layout field in the admin, will have no affect (e.g. {fuel_set_var('layout', 'my_layout')}).
Returns
void
Parameters
(string) $key (array) $val
fuel_var_append('$key', '$value')
Appends a value to an array variable for all views to use no matter what view it is declared in.
Returns
void
Parameters
(string) $key (mixed) $value
Example
// EXAMPLE HEADER FILE ... <?php echo css('main'); ?> <?php echo css($css); ?> <?php echo js('jquery, main'); ?> <?php echo js($js); ?> ... // Then in your view file ... <php fuel_var_append('css', 'my_css_file.css'); fuel_var_append('js', 'my_js_file.js'); ?> <h1>About our company</h1> ...
fuel_var('$key', ['$default'=''], ['$edit_module'='pagevariables'], ['$evaluate'=FALSE])
Returns a variable and allows for a default value. Also creates inline editing marker. The default parameter will be used if the variable does not exist. The edit_module parameter specifies the module to include for inline editing. The evaluate parameter specifies whether to evaluate any php in the variables.
You should not use this function inside of another function because you may get unexepected results. This is because it returns inline editing markers that later get parsed out by FUEL. For example:
Returns
string
Parameters
(string) $key (string) $default (boolean) $edit_module
Example
// NO <a href="<?=site_url(fuel_var('my_url'))?>">my link</a> // YES <?=fuel_edit('my_url', 'Edit Link')?> <a href="<?=site_url($my_url)?>">my link</a>
fuel_edit('$id', ['$label'=NULL], ['$module'='pagevariables'], ['$is_published'=TRUE], ['$xoffset'=NULL], ['$yoffset'=NULL])
Sets a variable marker (pencil icon) in a page which can be used for inline editing. The id parameter is the unique id that will be used to query the module. You can also pass an id value and a field like so id|field. This will display only a certain field instead of the entire module form. Alternatively, you can now also just pass the entire object and it will generate the id, label, module and published values automatically. The is_published parameter specifies whether to indicate with the pencil icon that the item is active/published The label parameter specifies the label to display next to the pencil icon. The xOffset and yOffset are pixel values to offset the pencil icon.
Returns
string
Parameters
(mixed) $id (string) $label (string) $module (boolean) $is_published (int) $xoffset (int) $yoffset
fuel_cache_id(['$location'=NULL])
Creates the cache ID for the fuel page based on the URI. If no location value is passed, it will default to the current uri_path.
Returns
string
Parameters
(string) $location
fuel_url(['$uri'=''], ['$query_string'=FALSE])
Creates the admin URL for FUEL (e.g. http://localhost/MY_PROJECT/fuel/admin).
Returns
string
Parameters
(string) $uri (boolean) $query_string
fuel_uri(['$uri'=''], ['$query_string'=FALSE])
Returns the FUEL admin URI path.
Returns
string
Parameters
(string) $uri (boolean) $query_string
fuel_uri_segment(['$seg_index'=0], ['$rerouted'=FALSE])
Returns the uri segment based on the FUEL admin path.
Returns
string
Parameters
(int) $seg_index (boolean) $rerouted
fuel_uri_index(['$seg_index'=0])
Returns the uri index number based on the FUEL admin path.
Returns
int
Parameters
(int) $seg_index
fuel_uri_string(['$from'=0], ['$to'=NULL], ['$rerouted'=FALSE])
Returns the uri string based on the FUEL admin path.
Returns
string
Parameters
(int) $from (int) $to (boolean) $rerouted
is_fuelified()
Check to see if you are logged in and can use inline editing.
Returns
boolean
in_fuel_admin()
Check to see if you are in the FUEL admin.
Returns
boolean
fuel_user_lang()
Returns the user language of the person logged in... used for inline editing.
Returns
string
fuel_settings('$module', ['$key'=''])
Returns the setting(s) for a particular module.
Returns
mixed
Parameters
(string) $module Module name (string) $key Settings key (optional)