Trongate Docs
switch to dark modeswitch to dark mode
»
»
Loading Templates

Loading Templates

If you have successfully followed the instructions on the previous page then you should now have an HTML template inside your 'templates' folder.

You can now load your template from any other module with the following line of code:

$this->template('public');

Example

Let's assume that you'd like to have your own custom method inside our 'Welcome' controller (inside the 'welcome' module that comes with the framework).  If your method was to be named 'greeting' then we could easily have our 'greeting' method display the public template like so:

function greeting() {
    $this->template('public');
}
  

As you can see, this is very easy.  However, there is one rather obvious problem: we haven't passed information from our module to our template!

Obviously, templates aren't much use if they just contain hard coded HTML.  Our goal will almost always be to have templates that are dynamic.  This means that our templates should be able to receive and display information from the methods from where they have been called.

We'll cover this on the next page.


HELP & SUPPORT

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

 
×