FUEL helper
Contains FUEL specific functions. This helper actually exists in the fuel module and should be loaded the following way:
$this->load->module_helper(FUEL_FOLDER, 'fuel');
The following functions are available:
fuel_block(params)
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 - a view file located in the views/_blocks
- view_string - a string value to be used for the view
- model - the model to load and be available for the view
- find - the find method on the model to use (e.g. 'one', 'all' or 'key')
- select - the select condition to filter the results of the find query
- where - the where condition on the model to be used in the find query
- order - order the data results returned from the model and sort them
- limit - limit the number of data results returned by the model
- offset - offset the data results returned by the model
- 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
- data - data to be passed to the view if a model isn't provided. This information can be accessed in the block from the variable $data
- editable - insert in inline editing
- parse - parse the contents of the page. Default is set to 'auto' which will NOT try and parse if your fuel_mode value in the fuel config file is set to "views".
- vars - additional variables to pass to the block
- cache - will cache the block
fuel_model(module, [params])
Loads a module's model and creates a variable that you can use to merge data into your view. The params parameter is an associative array that can have the following values:
- find - the find method to use on the module model
- 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
fuel_nav(params)
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:
- 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
- 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
- return_normalized - returns the raw normalized array that gets used to generate the menu
For more information see the Menu class.
fuel_set_var(key, val)
Sets a variable for all views to use no matter what view it is declared in.
fuel_var(key, [default], [edit_module], [evaluate])
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, you shouldn't do:
// NO
<a href="<?=site_url(fuel_var('my_url'))?>">my link</a>
Instead you should use fuel_edit() like so:
// YES
<?=fuel_edit('my_url', 'Edit Link')?> <a href="<?=site_url($my_url)?>">my link</a>
fuel_edit(id, [label], [module], [xOffset], [yOffset])
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. 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.
fuel_var_append(key, value)
Appends a value to an array variable. This function makes it convenient if you are in a view file and want to say add a javascript file to your $js array variable for example. The $js variable can then be passed to the asset helper's js($js) function with the appended values. The key value is the name of the array variable you want to append to. The value can be either an array or a string. An array will merge the values.
// EXAMPLE HEADER FILE
...
<meta name="keywords" content="<?php echo fuel_var('meta_keywords')?>" />
<meta name="description" content="<?php echo fuel_var('meta_description')?>" />
<?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');
?>
About our company
...
fuel_cache_id([location])
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.
fuel_url([uri])
Creates the admin URL for FUEL (e.g. http://localhost/MY_PROJECT/fuel/admin).
fuel_uri([uri])
Returns the FUEL admin URI path.
fuel_uri_segment([seg_index], [rerouted])
Returns the uri segment based on the FUEL admin path.
fuel_uri_index([seg_index])
Returns the uri index number based on the FUEL admin path.
fuel_uri_string([from], [to], [rerouted])
Returns the uri string based on the FUEL admin path.
is_fuelified()
Check to see if you are logged in and can use inline editing. Is an alias to the Fuel_auth::is_fuelified().