Trongate Docs
switch to dark modeswitch to dark mode
»
»
Understanding View Files

Understanding View FIles

View files are files that contain presentation code - such as HTML code (though sometimes other types of code such as JavaScript and/or CSS). The normal practice, when using Trongate, is to have a folder called 'views' inside each of your modules.

the structure of a Trongate module

Views folders exist at the same directory level as 'controllers' directories, however, strictly speaking - views directories are optional. In other words, sometimes you may have modules that contain no HTML whatsoever. An example of such a module might be a 'Paypal' module that is designed to receive payment information from Paypal.

How View Files Work

View files usually get called from controller files. In the Trongate Framework, view files are always .php files - however - the code within the .php files is mostly presentation code such as HTML.

View files can be called (loaded) from within controller methods by loading up Trongate's inbuilt 'view' function. For example:

$this->view('welcome');

The line of code above would be called from inside a method, within a Trongate controller class.  By invoking Trongate's inbuilt view() method, the framework would attempt to display a file (stored within the views folder) named welcome.php.


HELP & SUPPORT

If you have a question or a comment relating to anything you've see here, please goto the Help Bar.

 
×