Nullified Posted August 1, 2012 Share Posted August 1, 2012 {php}print count($gateways);{/php} I am using the above code to print out the count of items in the $gateways array, however it outputs 0 every time, even with recursive counting. I know the array contains 3 gateways based on the debug output. Can anyone shed some light on why this is not working as planned? What I am trying to do is create an if statement that hides the gateway radio boxes (payment method selection area) if the available gateway count is one: {if ($selectedgatewaytype eq "CC") and (count($gateways) eq 1)} style="display: none;"{/if} 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted August 3, 2012 Author Share Posted August 3, 2012 Anybody know? 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted August 7, 2012 Author Share Posted August 7, 2012 I guess this thread is a lost cause... 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted August 7, 2012 Share Posted August 7, 2012 (edited) $gateways is a smarty var and wont show under that var in php code try [color=#000000][color=#007700]{[/color][color=#0000BB]php[/color][color=#007700]}print [/color][color=#0000BB]count[/color][color=#007700]([/color][color=#0000BB]$this->_tpl_vars->gateways[/color][color=#007700]);{/[/color][color=#0000BB]php[/color][color=#007700]}[/color][/color] or in smarty (not tested) {$gateways|count} [color=#000000][color=#007700]{if [/color][color=#0000BB]$selectedgatewaytype eq [/color][color=#DD0000]"CC"[/color][color=#007700] AND [/color][color=#0000BB]$gateways|count [/color][color=#0000BB]eq 1[/color][color=#007700]} [/color][color=#0000BB]style[/color][color=#007700]=[/color][color=#DD0000]"display: none;"[/color][color=#007700]{/if} [/color][/color] Edited August 7, 2012 by sparky 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted August 7, 2012 Author Share Posted August 7, 2012 $this->_tpl_vars->gateways did not work and {$gateways|count} is an array 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted August 7, 2012 Share Posted August 7, 2012 (edited) Yep... just tested it and see what you mean... had it wrong sorry try this {php}$this->assign("numgateways" , count($this->_tpl_vars["gateways"]));{/php} [color=#000000][color=#007700]{if [/color][color=#0000BB]$selectedgatewaytype eq [/color][color=#DD0000]"CC"[/color][color=#007700] AND [/color][color=#0000BB]$[/color][/color]numgateways [color=#000000][color=#0000BB]eq 1[/color][color=#007700]} [/color][color=#0000BB]style[/color][color=#007700]=[/color][color=#DD0000]"display: none;"[/color][color=#007700]{/if}[/color][/color] Not sure why you want that as if there is only 1 gateway it is hidden Edited August 7, 2012 by sparky 0 Quote Link to comment Share on other sites More sharing options...
Eduardo G. Posted August 7, 2012 Share Posted August 7, 2012 From smarty template: <p>There are {$gateways|@count} gatewaya</p> (See the previously missing '@') From PHP: echo count($GLOBALS['availablegateways']); 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted August 8, 2012 Author Share Posted August 8, 2012 From smarty template: <p>There are {$gateways|@count} gatewaya</p> This worked like a charm. Thanks to both of you for your time. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.