CMSMS - CGBlog如何输出html除了最后一个条目?

时间:2014-07-15 15:41:51

标签: content-management-system smarty smarty3

我是CMSMS的新手,我正在使用CGblog,我有一个列表模板,一切正常,但我需要阻止HR标签显示在最后一项上。无法找出正确的编码方式。

CMS Made Simple™1.11.10“Pinzon”

{foreach from=$items item=entry}
<div class="CGBlogSummary">

      <article>

        <h3><a href="{$entry->detail_url}">{$entry->title|escape}</a></h3>
        <p style="font-size: 12px;">{if $entry->author}Written by <a href="">{$entry->author}</a>{/if}{if $entry->postdate} on {$entry->postdate|cms_date_format}.{/if}</p>

        <div class="row">
          <div class="large-6 columns">
            {if isset($entry->extra)}
                <div class="CGBlogSummaryExtra">
                    {eval var=$entry->extra}
              { {cms_module module='Uploads' mode='simpleurl' upload_id=$entry->extravalue} }
                </div>
            {/if}
            {if isset($entry->fields)}
              {foreach from=$entry->fields item='field'}
                 <div class="CGBlogSummaryField">
                    {if $field->type == 'file'}
                      <img src="{$entry->file_location}/{$field->value}"/>
                    {else}
                      {$field->name}:&nbsp;{eval var=$field->value}
                    {/if}
                 </div>
              {/foreach}
            {/if}
          </div>
          <div class="large-6 columns">
            {if $entry->summary}
              {eval var=$entry->summary}            
            {else if $entry->content}
                {eval var=$entry->content}
            {/if}
            <p><a href="{$entry->detail_url}">Read more...</a></p>
          </div>
        </div>
      </article>

      <hr /><!-- this should not be output on the final iteration of the loop-->

</div>
{/foreach}

2 个答案:

答案 0 :(得分:1)

我相信您可以使用语法:

<hr {if $entry@last} style='display:none' {/if} />

(如果它是最后一个条目,则使用css隐藏小时),虽然快而又脏!

答案 1 :(得分:1)

您可以简单地更改此行:

<hr /><!-- this should not be output on the final iteration of the loop-->

{if not $entry@last}<hr />{/if}