PDA

View Full Version : Need help with Smarty/Foreach/Free domains



othellotech
04-23-07, 09:26 AM
What with template systems in general, and smarty in particular, being a PITA to work with, I'm having an "interesting" time with adjusting step two of the orderform regarding free domains.

Despite coding the $freedomaintlds section to be in a fixed width table, the list of TLDs is about 55 screens wide, not 400 pixels ...



{if $freedomaintlds}
<table width="400" align="center" border="1">
<tr><th>* {$LANG.orderfreedomainregistration} {$LANG.orderfreedomainappliesto}: </th></tr>
<tr><td>{$freedomaintlds}</td></tr>
</table>
{/if}

Is ignoring the table width and making it 100% of the required width for the content - one day someone will invent a computer that actualy does what its bloody-well-told-to-do !

Anyway, what I actually want is to control how many tlds on each line, or to check if every tld is there and output a different message etc.

So in *theory* ...



{$freetlds = explode(",", $freedomaintlds)}
{foreach $freetlds as $freetld}
$freetld -
{/foreach}


should output each of the tlds one at a time with " - " between them - which would be a start. Sadly no output at all.

Its the foreach it cant cope with, and I've been staring at it way too long to be able to spot wood-from-trees and see the error, so any pointers much appreciated

othellotech
03-25-09, 01:29 AM
with many thanks to Matt @ WHMCS ...


{if $freedomaintlds}
* <em>{$LANG.orderfreedomainregistration} {$LANG.orderfreedomainappliesto}</em>
<table>
<tr>
{php}
$freedomaintlds = $this->_tpl_vars["freedomaintlds"];
$freedomaintlds = explode(",",$freedomaintlds);
$freedomaintldsbreakat = 13;
foreach($freedomaintlds as $key=>$value)
{
if ($freedomaintldscounter % $freedomaintldsbreakat == 0)
{
echo "</tr><tr>";
}
$freedomaintldscounter++;
echo "<td>$value</td>";
}
{/php}
</tr>
</table>
{/if}

displays them neatly in a table 13 cells wide - adjust to suit
goes in steptwo and configureproducdomain - just look for the freedomaintlds part :D