setting a boolean variable on template

Author Message

sean foley

Thursday 30 July 2009 8:55:53 am

I am trying to find the best method to process my template, in a nutshell part of my webapp extension is getting contact information from the customer, eg isMailContactAllowed, isPhoneContactAllowed, isSmsContactAllowed etc
When I get the query results back from the database I then want to display them on the template for the customer. so if they are true contact is allowed etc etc.
so at the moment I fell my method is not entirely efficient. and I would like to know some better method to proccess this data to the template.
this is how my code is on the ModuleView for Contact

if ($enet_cust->getMailContactAllowed() == true)
{
$option = true;
$oagContactByMail = 1;
}
else
{
$option = true;
$oagNoContactByMail = 1;
}

$tpl = templateInit();
$tpl->setVariable('option',$option);
$tpl->setVariable('oagContactByMail',$oagContactByMail);
$tpl->setVariable('oagNoContactByMail',$oagNoContactByMail);
$Result = array();
$Result['content'] = $tpl->fetch
( 'design:managemodule/contactoptions.tpl' );

then on my template I have something like this

{section show=$option}
{section show=or($oagContactByMail,$oagNoContactByMail,$oagContactByPhone,$oagContactByEmail,$oagContactBySms,$oagContactByFax)}
{section show=$oagContactByMail}<label>{"Contact me by Mail"|i18n("design/standard/user")}</label><div class="labelbreak"></div>{/section}
{section show=$oagNoContactByMail}<label>{"Don't Contact me by Mail"|i18n("design/standard/user")}</label><div class="labelbreak"></div>{/section}

{/section}
{/section}

I know this works but is it the right way to go about this????

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:21:16
Script start
Timing: Jan 18 2025 16:21:16
Module start 'layout'
Timing: Jan 18 2025 16:21:16
Module start 'content'
Timing: Jan 18 2025 16:21:16
Module end 'content'
Timing: Jan 18 2025 16:21:16
Script end

Main resources:

Total runtime0.0158 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 588.0313152.6406
Module start 'layout' 0.00620.0030 740.671939.4609
Module start 'content' 0.00920.0049 780.132889.2109
Module end 'content' 0.01410.0017 869.343830.3047
Script end 0.0158  899.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.2787140.0002
Check MTime0.00106.4758140.0001
Mysql Total
Database connection0.00064.035710.0006
Mysqli_queries0.003320.747130.0011
Looping result0.00000.095010.0000
Template Total0.00159.210.0015
Template load0.00074.364510.0007
Template processing0.00084.782210.0008
Override
Cache load0.00042.808110.0004
General
dbfile0.00031.613780.0000
String conversion0.00000.049840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs