What are controller files?
The controller file controls a specific part or layout.
Controller files (control.php) contain all the commands needed to connect the model with the view. The PHP classes that mainly being used in these controller files are the H4 Temp and H4 Get classes.
Besides the part
script can be used in the root path of the theme
. However this is not very common. If used in the root then it is the very first script that is being included even before the layout
. This concludes the systematical layout
given in the topic about themes
Several standard variables can be used in the controller file.
Depending on the theme level you can use some standard variables. These variables are named $aTheme, $aLayout and $aPart. Like the variable names suggest they contain the specific values that are assigned to the level you are in. So for example in the layout you can use $aTheme and $aLayout, when editing a part you can use all three ($aTheme, $aLayout and $aPart).
The array of a variable contains the data structure that was given in the model file. So when in the model file the variable $aModel['fields']['name'] is used then this variable is called in the part $aPart['name'].
For controlling the output the class H4 Temp is used. This is the same class that is used for outputting the view.
For setting the variables in the view the class H4 Temp is used. This class is called in every level of the layout (so not in the theme level). In the layout level the object name is $oLayout and in the part level $oPart. Following up is a list of common commands used.
Assigns a variable with the value of $sValue to the template variable $sKey. Important is that the variable $sKey exists in the template. Example of the setVar function in the $oPart :
Ads extra CSS styling to the template. $sValue can contain a link to a CSS file or the actual CSS styling script. Optional the type of the script can be added in $sType. Normally this function is only used in combination with the layout. This because the layout usually contains the header of the HTML. For example the style print or mobile. Example of the setCss function :
There are several special controller file settings that effect the rendering,
There are several special controller file settings that effect the rendering, Following up is a list of some special settings that can be used in a controller file.
When true creates a set of CSS files that contains all the seperate CSS files and coding ordered by media. For example one CSS file for the screen, one for mobile and one for print. Default is false. The setting should only being set in the $oLayout object. Example: