Introduction
Basic Concepts
Understanding Routing
Controllers
Views
Assets
Modules Calling Modules
Parent & Child Modules
Database Operations
Modules within Modules
Templates & Themes
Helpers Explained
Form Handling
Working with Files
The Module Import Wizard
Authorization & Authentication
The API Explorer
If you’ve found an error, spotted something missing, or feel a section could be clearer or better explained, we’d love to hear from you. Your feedback helps keep the documentation accurate and useful for everyone.
Please report issues or suggest improvements on GitHub. Community input is invaluable in making the docs stronger.
Not comfortable with GitHub? No problem — you can also get in touch with us directly via our contact form. We welcome all feedback.
Automatic URL Routing
Trongate's automatic routing system follows a simple, predictable pattern to map URLs to your code. When Trongate receives a URL request, it breaks the URL into segments and uses these segments to determine which code to run.
How URL Segments Work
Consider this example URL:
Trongate splits this URL into three segments and uses them in a specific way:
Segment | Example | Purpose |
---|---|---|
First Segment | members |
Names both the module folder and the controller to use |
Second Segment | profile |
Names the method to run |
Third Segment | 88 |
Passed as a parameter to the method (optional) |
Given the URL above, Trongate will:
- Look for a 'members' module folder
- Find the 'Members' controller inside that folder
- Run the 'profile' method
- Pass '88' as a parameter to that method
Mapping URLs to Code
Here's what the corresponding code, based on our example, could look like:
Important Rules
- Module folders should be lowercase (e.g., 'members')
- Controller class names should have an uppercase first character (e.g., 'Members')
- Method names should be lowercase (e.g., 'profile')
- If no second segment exists, Trongate will look for an 'index' method
Custom URL routing will override automatic routing. If you have defined a custom route for a URL, that will take precedence over the automatic routing rules described here.
In Summary
Automatic routing makes it easy to add new functionality to your application - just create the appropriate module, controller, and methods, and Trongate will automatically make them accessible via URLs that follow this pattern.