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
Utilities Helpers
Utilities helpers are the odds and ends that don't fit anywhere else. Debugging, sorting, IP addresses, file info and view rendering.
Call them whenever:
- block_url() block direct URL access to controller methods
- json() debug output in pretty JSON
- ip_address() get the client's IP
- display() render views inside templates
- return_file_info() extract filename and extension
- sort_by_property() sort associative arrays
- sort_rows_by_property() sort object arrays
- from_trongate_mx() detect MX requests
Debug with JSON
The json() function dumps data in readable JSON format. Perfect for inspecting arrays and objects during development.
Output:
{
"name": "John",
"age": 30
}
Stop Execution
Pass true as the second argument to kill the script immediately after output:
Get Client IP
The ip_address() function returns the visitor's IP address.
Render Views
The display() function loads a view file from a module. Use it inside templates to inject content.
This loads modules/products/views/listing.php and passes $products to it.
Auto-Detection
If you don't specify view_module, it uses the first URL segment. If you don't specify view_file, it defaults to index.
If the view file doesn't exist, display() shows a red error message with the expected path.
Extract File Info
The return_file_info() function splits a file path into name and extension.
Sort Arrays
The sort_by_property() function sorts associative arrays by a specific key.
Sort Objects
The sort_rows_by_property() function does the same thing but for arrays of objects.
Detect Trongate MX Requests
The from_trongate_mx() function checks if the current request came from Trongate MX (Trongate's JavaScript library for dynamic page updates).
Use from_trongate_mx() to handle AJAX requests differently from normal page loads - no extra routing required.
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.