The newest feature in this regard is the ability to intercept and control fields and the way they display in forms as well as other outputs (ie views and viewlists).
Interception can take place at 3 levels for form-fields and for displaying variable values.
- Level 1: Global level - whenever the variable is 'called' it will look to your new method to render it to the engine.
- Level 2: Class/variable level - whenever the variable is called from forms within a specified class it will look to your new method to render it to the engine.
- Level 3: Field level - specified using a naming syntax within the variable name, your method will only be called when your specific custom named variable is called.
- For Form Fields:
- Within the BB2 Forms Engine we have a function which renders form-fields to the GUI engine. At it's simplest form it can be called with a BB2.0 Tag like this:
<!--:formfield:variable_name:--> - These new plugins essentially hi-jack the process that is invoked by this tag and allow you to determine what form-field element/s get rendered to the GUI when this variable is called
- To change the form-field globally for a variable name (ie cashbookISbb_finance_cashbooksID) you can use the class->method call within bb_plugins.php. To do this you will need a bb_plugins.php file in your custom_modules folder and then you will need to name/format your function as follows:
function formfield_cashbookISbb_finance_cashbooksID($conf=NULL){
//the value of $conf is an array with useful data in it
//most notably $conf[default] which is the current value, if any, for this variable
//for the full array simply resp_r($conf) at this point...
return("
<input
id=global[fields][cashbookISbb_finance_cashbooksID]
name=global[fields][cashbookISbb_finance_cashbooksID]
value='$conf[default]'
>");
}
In the above example you can see that you need to return a string with a form element in it, but this can be any combination of html, javascript, etc instructions. Basically, wherever this variable is called through the forms engine, this will be sent back to the form as the 'field'. - For a specific class/variable combination by using a bbsetting, namely bbsetting_field_display_formfield_plugins. This can be set within a PHP file as follows:
var $bbsetting_field_display_formfield_plugins=array("field_name"=>"method_to_call");
or it can be set using the Admin>Module Settings functionality by entering the field=>method pairs separated by commas ie:
field_name=method_name,
field_name2=method_name2,
You can set multiple field=>method values within this array. The 'method' can then sit within the bb_plugins class or the parent class where the bbsetting has been set, either place will work. The method can be styled exactly as per the function example above. So, just to drive the point home, in this instance, if the bbsetting was set in the bb_finance_cashbook_entries class, then only when forms within that class are rendering the cashbookISbb_finance_cashbooksID will this form-field override take effect. - On an ad-hoc basis within the variable/field name itself, by using the variable naming syntax as follows : variable_nameISPLUGIN_method_name. This behaves exactly as per the second example above, whereby it looks for the method within the bb_plugins class or, if it can detect a current related class to the variable, within the current class. The method can be styled exactly as per the function example above.
- Within the BB2 Forms Engine we have a function which renders form-fields to the GUI engine. At it's simplest form it can be called with a BB2.0 Tag like this:
- For Field Value Display:
- Within the BB2 GUI engine we have a function called item_display_value. This takes an input in the form of an array which specifies the variable name to display and any possible value/s for it. The function then determines how to render the variable/value to the GUI engine.
- These new plugin options essentially hi-jack this process and override the renderer with your bespoke method.
- To change the form-field globally for a variable name (ie cashbookISbb_finance_cashbooksID)
you can use the class->method call within bb_plugins.php. To do this
you will need a bb_plugins.php file in your custom_modules folder and
then you will need to name/format your function as follows:
function item_display_value_cashbookISbb_finance_cashbooksID($conf=NULL){
//the value of $conf is an array with useful data in it
//most notably $conf[1] which is the current value, if any, for this variable
//for the full array simply resp_r($conf) at this point...
return($conf[1]);
}
In the above example you can see that you need to return a string with the value as you want it represented in it, but this can be any combination of html, javascript, etcas required. Basically, wherever this variable is called through the GUI engine, this will be sent back as the value/output.
- For a specific class/variable combination by using a bbsetting,
namely bbsetting_field_display_plugins. This can be set
within a PHP file as follows:
var $bbsetting_field_display_plugins=array("field_name"=>"method_to_call");
or it can be set using the Admin>Module Settings functionality by entering the field=>method pairs separated by commas ie:
field_name=method_name,
field_name2=method_name2,
You can set multiple field=>method values within this array. The 'method' can then sit within the bb_plugins class or the parent class where the bbsetting has been set, either place will work. The method can be styled exactly as per the function example above. So, just to drive the point home, in this instance, if the bbsetting was set in the bb_finance_cashbook_entries class, then only when forms within that class are rendering the cashbookISbb_finance_cashbooksID will this form-field override take effect.
- On an ad-hoc basis within the variable name itself, by using the variable naming syntax of variable_nameISPLUGIN_method_name. This behaves exactly as per the second example above, whereby it looks for the method within the bb_plugins class or, if it can detect a current related class to the variable, within the current class. The method can be styled exactly as per the function example above.