Trongate PHP Framework Docs
Introduction
Quick Start
Basic Concepts
Understanding Routing
Intercepting Requests
Module Fundamentals
Database Operations
Templates
Helpers
Form Handling
Form Validation
Working With Files
Image Manipulation
Working With Dates & Times
Language Control
Security
Tips And Best Practices

Admin and Public Templates

Trongate v2 ships with two built-in templates:

  1. – the full admin panel layout (with sidebar, header, footer, and mobile navigation)
  2. – the clean public-facing layout (simple header, content area, and footer)

Use admin() for anything that needs a dashboard feel such as managing users, editing products, viewing reports, or handling orders. Use public() for everything else such as home pages, about pages, blog posts, contact forms, or landing pages.

How to Load Templates

From any controller:

Visit this URL →

Result: Full admin layout with your manage.php view injected inside.

For a public page:

Visit this URL →

Result: Clean public layout with your about.php view injected.


Understanding The Code – Line by Line

You’ll be writing this pattern a hundred times, so let’s be crystal clear about every single line.

1. The Method Name

public function manage(): void { … }

The method name (manage) becomes part of the URL. If this method lives in a controller called Users.php inside the users module, the URL is:

2. The $data Array

$data is just a normal PHP associative array. Anything you put in here becomes available inside both the template and the injected view file.

3. Setting a Page Title (optional but common)

This line is only an example. You can pass anything you want - database rows, form errors, breadcrumbs, etc.

4. view_module (optional)

Tells the helper: “go look for the view file inside the users module”.

If you leave this out, Trongate will assume the view lives in the current module (the one that contains the controller you’re in). Explicit is safer and clearer.

5. view_file

Tells the helper: “load manage.php from the views folder”.

When declaring a view_file properties, the .php suffix is implied.

Therefore, the following would load homepage_content.php:

6. Loading the Template

This single line:

  • Processes any extra CSS/JS you might have added (more on that, next page)
  • Loads the admin template →
  • Inside that file, this injects your chosen view →
  • Outputs the complete HTML page

You can call $this->templates->public($data) exactly the same way. The only difference is which template file gets loaded.

We're continually improving the Trongate documentation. If anything is incorrect, unclear, incomplete, or could be better, we'd genuinely appreciate your input.

Share your thoughts in the Documentation Feedback.

Leave Feedback About This Page