For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > May 2004 > strange !!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author strange !!
Pete M

2004-05-11, 11:52 am

dont' know how to explain properly so here I go ;-)

I've got a set of tabs across the top of a page from this array

print_r()
$site_types = Array (
[0] => Array ( [site_type_id] => 1 [site_type] => Branches )
[1] => Array ( [site_type_id] => 2 [site_type] => Clients )
[2] => Array ( [site_type_id] => 3 [site_type] => Misc )
[3] => Array ( [site_type_id] => 0 [site_type] => All )
[4] => Array ( [site_type_id] => new [site_type] => New Site ) )
[5] => Array ( [site_type_id] => index [site_type] => Sites Index )
)

then the following statments

// set default
$site_type_id = ($_GET['site_type_id'] != '')? $_GET['site_type_id'] : 0;
$smarty->assign_by_ref('site_type_id', $site_type_id);

// site tabs
$smarty->assign_by_ref('ntabs',$site_types);

and a snippet of the template
<table><tr>

{if $ntabs[t].site_type_id == $site_type_id }
<td width="{$tab_width}" align="center"
background="images/selected.jpg">{$ntabs[t].site_type}</td>

{elseif $ntabs[t].site_type_id != $site_type_id }
<td width="{$tab_width}" align="center"
background="images/selected.jpg">{$ntabs[t].site_type}</td>

{/if}
</tr></table>


Now what happens is that when the default is set above to 0
the "New Site" and "Sites Index" are also selected

However setting the default to "0" makes it work ok ?

where is the "companison" type casting - in php or smarty ??

pete
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com