Nullified Posted July 26, 2011 Share Posted July 26, 2011 {foreach key=num item=domain from=$domains} {php} if (strlen($domain.domain) > 20) { $first = substr($domain.domain, 0, 7); $last = substr($domain.domain, -1, 10); $shortdomainame = $first."...".$last; }{/php} {/foreach} {if $shortdomainame}{$shortdomainame}{else}{$domain.domain}{/if} Ok so I am trying to trim the fat off excessively long domains on my orderform and this is not working for some reason. It appears that $domain.domain, $domains.domain, $domain and $domains are all inaccessible. Can someone please help. 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted July 26, 2011 Share Posted July 26, 2011 To see what variables are available for use at that exact point in the order form, add this to your Smarty TPL file: {debug} 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted July 26, 2011 Share Posted July 26, 2011 Didn't even read what tragic Smarty error you made! Sorry for jumping in with debug. You cannot access Smarty variables inside {php} tags. Simple solution is to not use {php} tags. Use Smarty functions, and lots of documentation can be found here: http://www.velvetblues.com/web-development-blog/smarty-templates-create-custom-functions/ If you really, really need to break out into {php} then you can use this PHP code inside {php} tags to get a variable: $var_name = $this->get_template_vars("var_name"); But I wouldn't advise that method, go with a custom function, they're re-usable too. 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted July 26, 2011 Author Share Posted July 26, 2011 Didn't even read what tragic Smarty error you made! Sorry for jumping in with debug. You cannot access Smarty variables inside {php} tags. Simple solution is to not use {php} tags. Use Smarty functions, and lots of documentation can be found here: http://www.velvetblues.com/web-development-blog/smarty-templates-create-custom-functions/ If you really, really need to break out into {php} then you can use this PHP code inside {php} tags to get a variable: $var_name = $this->get_template_vars("var_name"); But I wouldn't advise that method, go with a custom function, they're re-usable too. Thanks for the point in the right direction. function smarty_function_trim($params, &$smarty) { $output = $params['domain']; if (strlen($params['domain']) > 20) { $output = substr($params['domain'], 0, 5)."...............".substr($params['domain'], -10); } return $output; } {trim domain=$domain.domain} 0 Quote Link to comment Share on other sites More sharing options...
Grizzlyware Josh Posted July 26, 2011 Share Posted July 26, 2011 Correct But make sure the function goes in the correct file & plugin folder as described on Smarty docs. Smarty can be found at: whmcs/includes/smarty/ 0 Quote Link to comment Share on other sites More sharing options...
Nullified Posted July 27, 2011 Author Share Posted July 27, 2011 Yea, I found it all and made the file and it worked fine. 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.