The Trongate PHP Framework
Documentation
Introduction
Quick Start
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
Best Practices

Help Improve Our Docs

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.

The Module Assets Trigger

In the example from the previous page, a JavaScript file was successfully served from deep within our 'modules' directory. The target JavaScript file was loaded by setting a source ('src') value of:

welcome_module/js/ahoy.js

Under normal circumstances, such a short and concise file destination would produce file loading errors. However, the JavaScript file could be loaded without issue by invoking Trongate's Module Assets Trigger.

Understanding the Module Assets Trigger

The Module Assets Trigger serves as a specific string included in website URLs or file paths. When encountered, the File Asset Manager initiates a process to locate the requested asset within a module's assets directory. Assuming the file exists, the File Asset Manager handles the necessary file retrieval and response headers, facilitating modular development.

By default, the Trongate framework's Module Assets Trigger is defined as the string '_module'. Any path containing this trigger prompts Trongate to identify and fetch files from the respective module's assets directory.

If any part of a URL or file path contains the Module Assets Trigger, Trongate's File Asset Manager will be invoked and the framework will attempt to serve files from within the application's 'modules' directory. This can lead to confusion and unwanted 404 errors. Therefore, it's advisable to exercise caution when naming modules and files. In particular, steps should be taken to ensure that modules and files do not contain the Module Assets Trigger within their assigned names.

Configuration and Usage

The Module Assets Trigger is configured within the config.php file using the following line:

This configuration instructs Trongate to detect and interpret URLs or file paths containing '_module' to fetch assets from the corresponding module's assets directory. For example, to reference a file within the 'cars' module, the path should begin with:

This indicates that the asset is located within the 'assets' subdirectory of the 'cars' module.

Customization Options

If customization of the Module Assets Trigger is necessary to suit specific preferences or naming conventions, simply modify the value assigned to MODULE_ASSETS_TRIGGER in the config.php file.

When developing applications that interact with user input, consider implementing validation rules to prevent inadvertent triggering of the File Asset Manager. For instance, ensure that user-generated URLs or paths do not inadvertently contain the Module Assets Trigger phrase.

×