Jump to content

Recommended Posts

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 by Bamarama
Link to comment
https://forums.phpfreaks.com/topic/274941-multiple-columns-on-tpl-page/
Share on other sites

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.

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.