0

干草每个人都需要一些帮助,因为我是编码新手。

例如,我怎样才能让每隔一个季节浮动。

第 1 季第 1 集

然后浮动第 2 季

第 2 季第 1 集

第 4、6、8 季也是如此,你明白我的意思。

<ul class="episodes">
   <div class="tv_container"> 
  {foreach from=$episodes key=id item=val name=episode_loop}
  {if $val.episode eq 1}
      <h2>Season {$val.season}</h2>
  {/if}
<h5 class="episode_item">
{if $global_settings.seo_links}
   <a class="link" href="{$baseurl}/{$routes.show}/{$val.perma}/season/{$val.season}/episode/{$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">Episode {$val.episode}{if $val.episodetitle} <span class="tv_episode_name"> - {$val.episodetitle}</span>{/if}</a>
{else}
   <a class="link" href="{$baseurl}/index.php?menu=episode&perma={$val.perma}&season={$val.season}&episode={$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}   </a>
{/if}
</h5>
</li>
   {if $smarty.foreach.episode_loop.iteration % 4 eq 0}<div class="clear"></div>{/if}
{/foreach}
</div>
</ul>

请帮忙。

谢谢

4

2 回答 2

0

我相信这样的事情;

<ul class="episodes">
    <div class="tv_container"> 
        {foreach from=$episodes key=id item=val name=episode_loop}
            {if $val.episode eq 1}
                <h2>Season {$val.season}</h2>
            {/if}
            <h5 class="episode_item" {if $smarty.foreach.episode_loop.iteration % 2 eq 0}style="float:right;"{/if}>
                {if $global_settings.seo_links}
                    <a class="link" href="{$baseurl}/{$routes.show}/{$val.perma}/season/{$val.season}/episode/{$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">Episode {$val.episode}{if $val.episodetitle} <span class="tv_episode_name"> - {$val.episodetitle}</span>{/if}</a>
                {else}
                    <a class="link" href="{$baseurl}/index.php?menu=episode&perma={$val.perma}&season={$val.season}&episode={$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}   </a>
                {/if}
            </h5>
            {if $smarty.foreach.episode_loop.iteration % 2 eq 1}<div class="clear"></div>{/if}
        {/foreach}
    </div>
</ul>
于 2013-08-16T07:51:55.993 回答
0

我稍微修改了你的 HTML,但你应该可以使用它来让它工作。

<ul class="seasons">
    {foreach from=$episodes key=id item=val name=episode_loop}
        {if !isset($lastSeason)}
            <ul class="episodes">
            <li>
                <h2>Season {$val.season}</h2>
        {elseif $lastSeason != $val.season}
            </ul>
            <ul class="episodes" style="float: right;">
            <li>
                <h2>Season {$val.season}</h2>
        {/if}
                <div class="tv_container"> 
                    <h5 class="episode_item">
                    {if $global_settings.seo_links}
                        <a class="link" href="{$baseurl}/{$routes.show}/{$val.perma}/season/{$val.season}/episode/{$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">Episode {$val.episode}{if $val.episodetitle} <span class="tv_episode_name"> - {$val.episodetitle}</span>{/if}</a>
                    {else}
                        <a class="link" href="{$baseurl}/index.php?menu=episode&perma={$val.perma}&season={$val.season}&episode={$val.episode}" title="{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}">{$lang.show_episode_title|replace:'#season#':$val.season|replace:'#episode#':$val.episode}   </a>
                    {/if}
                    </h5>    
                </div>
            </li>
            {assign var=lastSeason value=$val.season}
    {/foreach}
    </ul>
    <div class="clear"></div>
</ul>
于 2013-08-16T08:17:20.597 回答