The Bug Genie
The Bug Genie
Please log in to subscribe to updates for this article
The Bug Genie:Development:Template Variables
Last updated at Mon Feb 21 08:01, by System

Introduction  ⇑ top

This page lists all the variables available to action templates, component templates and template partials in The Bug Genie.

Any action variables  ⇑ top

Any variables that have been assigned in the action will be passed on to the template when the action is completed.

Examples: actions.class.php runIndex() action:
public function runIndex(TBGRequest $request)
	$this->my_variable = 'fu';

<?php echo $my_variable; // echoes "fu" ?>

$tbg_request  ⇑ top

In the template you can always access data from the request, via the $tbg_request variable. This is the same object you get when you do TBGContext::getRequest().

Example: mymodule/templates/index.php
<?php echo ($tbg_request->isMethod(TBGRequest::POST)) ? 'yes' : 'no'; // echoes "yes" if this was a post request, or "no" if it wasn't ?>

$tbg_response  ⇑ top

The template has access to the response object, which will be useful if you want to add javascript files, headers, feeds etc from your template. The response is also where you set the page title. $tbg_response is an instance of TBGResponse.

Example: mymodule/templates/index.php

$tbg_routing  ⇑ top

You can access the routing object from the template via $tbg_routing, which is an instance of the TBGRouting object, elsewhere accessed via TBGContext::getRouting(). This object can be used if you want to find out what specific action was run, what template was being included, etc.

Example: mymodule/templates/index.php
<?php echo $tbg_routing->getCurrentRouteModule(); // echoes "mymodule" ?>

$tbg_user  ⇑ top

This is the instantiated user object, which may or may not be logged in, depending on the security settings.

<?php echo ($tbg_user->isAuthenticated()) ? 'logged in' : 'not logged in'; ?>

Article attachments

There are no file attached to this article

Article comments (0)

There are no comments