Difference between revisions of "Template Array Variable"
From TMM Wiki
Jump to navigationJump to searchm |
(No difference)
|
Latest revision as of 13:24, 19 December 2008
There are numerous arrays used in the NATS templates. If you want to display or use only one record in the array you can set it up like this:
In the template place this code:
{include_php file="../includes/getvariable.php"} {$myVariable}
Replace getvariable.php and $myVariable with a names you'll remember.
On your server, go into the includes directory of NATS, create the getvariable.php script, and input the following code:
<? $myVar = $this->get_template_vars('smarty array'); $this->assign('myVariable', $myVar['key of array']); ?>
Replace smarty array with the name of the array you want to get variables from; replace array key with the name of the array element you want to use in your variable.
Example
You can use the following code to automatically place the default campaign on the members_codes template.
Add the following to the members_codes template:
{include_php file="../includes/get_campaign_id.php"} {$myCampaign}
Add the following to the includes/get_campaign_id.php file:
<? $myCamp = array_flip($this->get_template_vars('campaigns')); $this->assign('myCampaign', $myCamp['Default']); ?>