2013-11-25 3 views
-1

Мне нужна помощь в умении. Я хочу разбить мои результаты, но я не мог этого сделать. Когда я запускаю свой код, это похоже;«Smarty» Разделение divs на несколько столбцов?

GAME 1
GAME 2
GAME 3
GAME 4
GAME 5
GAME 6

Но я хочу, это выглядит так,

GAME 1 GAME 4
GAME 2 ИГРЫ 5
ИГРА 3 ИГРОВАЯ 6

или

ИГРЫ ИГРЫ 1 2
ИГРЫ ИГРЫ 3 4
ИГРЫ 5 ИГРЫ 6

Любые советы?

Заранее спасибо

{foreach from=$newgames item=games} 
<div style="height:120px; width:420px;"> 
<div class="gamepic"> 
         <a href="{$siteadres}/{$games.seobaslik}.html" alt="{$games.baslik}" title="{$games.baslik}"> 
          <img style="border:none; " src="{$games.resim}" alt="{$games.baslik}" data-original="{$games.resim}" height="100" width="100"/> 
         </a> 
</div> 
<div class="gamedesc"> 
<span class="gametitle">{$games.baslik}</span> 
<div class="itemcontent">{$games.aciklama}</div> 
<div style="float:left; padding-bottom:-15px;">Played: {$games.ptime}</div><div style="float:right;"> <a href="{$siteadres}/{$games.seobaslik}.html" title="{$games.baslik}"><img style="border:none;" src="{$siteadres}/temalar/{$tema}/images/play.png"/></a></div> 

</div> 
</div> 

      {/foreach} 
+1

Это может быть достигнуто с помощью CSS. http://css-tricks.com/all-about-floats/ –

ответ

0

Если вы используете Smarty3, вы должны использовать @index property, сделать модуль с числом столбцов и вставить закрыть/открыть DIV.

{* output empty row on the 4th iteration (when index is 3) *} 
<table> 
{foreach $items as $i} 
    {if [email protected] eq 3} 
    {* put empty table row *} 
    <tr><td>nbsp;</td></tr> 
    {/if} 
    <tr><td>{$i.label}</td></tr> 
{/foreach} 
</table> 

Или с помощью smarty 2 вы должны использовать документацию iteration property. :

<table> 
{section name=co loop=$contacts} 
    {if $smarty.section.co.iteration % 5 == 1} 
    <tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr> 
    {/if} 
    <tr> 
    <td><a href="view.php?id={$contacts[co].id}">view<a></td> 
    <td>{$contacts[co].name}</td> 
    <td>{$contacts[co].home}</td> 
    <td>{$contacts[co].cell}</td> 
    <td>{$contacts[co].email}</td> 
    <tr> 
{/section} 
</table> 

Как Мэтью Blancarte говорит, что вы можете сделать с помощью CSS3 like this или с этим other method

Смежные вопросы