Bamarama Posted February 25, 2013 Share Posted February 25, 2013 (edited) Hello all. I am not sure if this is the correct forum for this question or not. If not, by all means steer me in the right direction please. Also, sorry for cross-posting.... I did not see how to delete off the other forum. I am making a variation on a game that uses PHP and tpl files. My question is this: How can I make my DB rows have 2 or more columns rather than the standard on the tpl page. Here is the code on the tpl page: {block name="title" prepend}{$LNG.lm_buildings}{/block} {block name="content"} {if !empty($Queue)} <div id="buildlist" class="buildlist"> <table style="width:760px"> {foreach $Queue as $List} {$ID = $List.element} <tr> <td style="width:70%;vertical-align:top;" class="left"> {$List@iteration}.: {if !($isBusy.research && ($ID == 6 || $ID == 31)) && !($isBusy.shipyard && ($ID == 15 || $ID == 21)) && $RoomIsOk && $CanBuildElement && $BuildInfoList[$ID].buyable} <form class="build_form" action="game.php?page=buildings" method="post"> <input type="hidden" name="cmd" value="insert"> <input type="hidden" name="building" value="{$ID}"> <button type="submit" class="build_submit onlist">{$LNG.tech.{$ID}} {$List.level}{if $List.destroy} {$LNG.bd_dismantle}{/if}</button> </form> {else}{$LNG.tech.{$ID}} {$List.level} {if $List.destroy}{$LNG.bd_dismantle}{/if}{/if} {if $List@first} <br><br><div id="progressbar" data-time="{$List.resttime}"></div> </td> <td> <div id="time" data-time="{$List.time}"><br></div> <form action="game.php?page=buildings" method="post" class="build_form"> <input type="hidden" name="cmd" value="cancel"> <button type="submit" class="build_submit onlist">{$LNG.bd_cancel}</button> </form> {else} </td> <td> <form action="game.php?page=buildings" method="post" class="build_form"> <input type="hidden" name="cmd" value="remove"> <input type="hidden" name="listid" value="{$List@iteration}"> <button type="submit" class="build_submit onlist">{$LNG.bd_cancel}</button> </form> {/if} <br><span style="color:lime" data-time="{$List.endtime}" class="timer">{$List.display}</span> </td> </tr> {/foreach} </table> </div> {/if} <table style="width:760px"> {foreach $BuildInfoList as $ID => $Element} <tr> <td rowspan="2" style="width:120px;"> <a href="#" onclick="return Dialog.info({$ID})"> <img src="{$dpath}gebaeude/{$ID}.gif" alt="{$LNG.tech.{$ID}}" width="120" height="120"> </a> </td> <th> <a href="#" onclick="return Dialog.info({$ID})">{$LNG.tech.{$ID}}</a>{if $Element.level > 0} ({$LNG.bd_lvl} {$Element.level}{if $Element.maxLevel != 255}/{$Element.maxLevel}{/if}){/if} </th> </tr> <tr> <td> <table style="width:100%"> <tr> <td class="transparent left" style="width:90%;padding:10px;"><p>{$LNG.shortDescription.{$ID}}</p> <p>{foreach $Element.costRessources as $RessID => $RessAmount} {$LNG.tech.{$RessID}}: <b><span style="color:{if $Element.costOverflow[$RessID] == 0}lime{else}red{/if}">{$RessAmount|number}</span></b> {/foreach}</p></td> <td class="transparent" style="vertical-align:middle;width:100px"> {if $Element.maxLevel == $Element.levelToBuild} <span style="color:red">{$LNG.bd_maxlevel}</span> {elseif ($isBusy.research && ($ID == 6 || $ID == 31)) || ($isBusy.shipyard && ($ID == 15 || $ID == 21))} <span style="color:red">{$LNG.bd_working}</span> {else} {if $RoomIsOk} {if $CanBuildElement && $Element.buyable} <form action="game.php?page=buildings" method="post" class="build_form"> <input type="hidden" name="cmd" value="insert"> <input type="hidden" name="building" value="{$ID}"> <button type="submit" class="build_submit">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</button> </form> {else} <span style="color:red">{if $Element.level == 0}{$LNG.bd_build}{else}{$LNG.bd_build_next_level}{$Element.levelToBuild + 1}{/if}</span> {/if} {else} <span style="color:red">{$LNG.bd_no_more_fields}</span> {/if} {/if} </td> </tr> </table> </td> </tr> <tr> <td colspan="2" style="margin-bottom:10px;"> <table style="width:100%"> <tr> <td class="transparent left"> {$LNG.bd_remaining}<br> {foreach $Element.costOverflow as $ResType => $ResCount} {$LNG.tech.{$ResType}}: <span style="font-weight:700">{$ResCount|number}</span><br> {/foreach} <br> </td> </tr> <tr> <td class="transparent left" style="width:68%"> {if !empty($Element.infoEnergy)} {$LNG.bd_next_level}<br> {$Element.infoEnergy}<br> {/if} {if $Element.level > 0} {if $ID == 43}<a href="#" onclick="return Dialog.info({$ID})">{$LNG.bd_jump_gate_action}</a>{/if} {if ($ID == 44 && !$HaveMissiles) || $ID != 44}<br><a class="tooltip_sticky" data-tooltip-content=" {* Start Destruction Popup *} <table style='width:300px'> <tr> <th colspan='2'>{$LNG.bd_price_for_destroy} {$LNG.tech.{$ID}} {$Element.level}</th> </tr> {foreach $Element.destroyRessources as $ResType => $ResCount} <tr> <td>{$LNG.tech.{$ResType}}</td> <td><span style='color:{if $Element.destroyOverflow[$RessID] == 0}lime{else}red{/if}'>{$ResCount|number}</span></td> </tr> {/foreach} <tr> <td>{$LNG.bd_destroy_time}</td> <td>{$Element.destroyTime|time}</td> </tr> <tr> <td colspan='2'> <form action='game.php?page=buildings' method='post' class='build_form'> <input type='hidden' name='cmd' value='destroy'> <input type='hidden' name='building' value='{$ID}'> <button type='submit' class='build_submit onlist'>{$LNG.bd_dismantle}</button> </form> </td> </tr> </table> {* End Destruction Popup *} ">{$LNG.bd_dismantle}</a>{/if} {else} {/if} </td> <td class="transparent right" style="white-space:nowrap;"> {$LNG.fgf_time}:<br>{$Element.elementTime|time} </td> </tr> </table> </td> </tr> {/foreach} </table> {/block} Edited February 25, 2013 by Bamarama Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2013 Share Posted February 25, 2013 Honestly that's way too much code for most of us to bother reading. Are you asking how to create a table with two columns in HTML? Because that's all your tpl is, a wrapper for HTML. Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 25, 2013 Author Share Posted February 25, 2013 Well yes, basically. Sorry for the large amount of code but I was unsure of what would be needed.. I know that somewhere at the top is where things need to change. I just want these rows to show on multiple columns. It can be two or 3, depending on how it looks. I know I need to set a $column variable somewhere and need to use this for the script, I just do not know where or how. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2013 Share Posted February 25, 2013 Is that Smarty? The foreach syntax isn't what I've seen. Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 25, 2013 Author Share Posted February 25, 2013 Yes, smarty is used on this site. Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 25, 2013 Author Share Posted February 25, 2013 I am guessing by your silence that this is not in your realm? Can you point me towards someone who would know about this? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2013 Share Posted February 25, 2013 You expect an answer immediately? Geez. I was going to find you the page on the Smarty site that covers it but now I'll just say go find it. Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 25, 2013 Author Share Posted February 25, 2013 I wasn't being smart. I was just saying that at first you responded quickly then asked about smarty, then silence. Please do not think I was being demanding, as that was not my intention at all. Any help you can provide would be most helpful. Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 26, 2013 Author Share Posted February 26, 2013 Seriously. I did not mean bad by my comment. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 26, 2013 Share Posted February 26, 2013 In any of the time that's passed did you bother to go look at Smarty's site? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 26, 2013 Share Posted February 26, 2013 You just need to use % or use the Smarty table functionality. http://www.smarty.net/docsv2/en/language.function.html.table.tpl http://stackoverflow.com/questions/14455396/smarty-table-even-odd Quote Link to comment Share on other sites More sharing options...
Bamarama Posted February 26, 2013 Author Share Posted February 26, 2013 I did look at the smarty pages. I am not sure how to incoorperate that with what I have. The smarty pages have their own section defining variables and all that before the page I have is even called. The smarty variables can be passed without defining them I should say. I am looking at the html_tables now and see if I can figure that out. Thanks for the direction 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.