判斷Smarty的foreach迴圈第1次及最後1次

如果是這個foreach的第一個迴圈,出現紅色框框裡的線

{if $smarty.foreach.homeblog.first == true}

只要這個foreach不是最後一個迴圈,則出現紅色框框裡面的線,不然就不要出現紅色框框裡面的線

{if $smarty.foreach.homeblog.last != true}

原始程式碼:

{if $home_blog_status == "1"}
    {foreach from=$home_blog item=blog name=homeblog}
        {if $smarty.foreach.homeblog.first == true}
            {if $hr == "y"}<img src='upload/update_img/hr.png' />{else}<img src='default/images/hr.gif' />{/if}
        {/if}
        {if $blog.id}
            <div class = 'listType_single'>
                {if $blog.pic}
                    <div class='listType_img'><a href='{$php_self}?mod=blog&fun=blog_article_show&blog_id={$blog.id}{if $category_type_blog == 1}&from=blog_date{/if}'><img src='upload/blog/s/{$blog.pic}' alt='{$blog.title}' title='{$blog.title}' /></a></div>
                {/if}
                <div class = 'listType_title'><a href='{$php_self}?mod=blog&fun=blog_article_show&blog_id={$blog.id}{if $category_type_blog == 1}&from=blog_date{/if}'>{$blog.title}</a></div>
                <div class = 'listType_content'>{$blog.content}</div>
            </div>
            <div class = 'listType_more'>
                {if $blog.catid}<span><a href="{$php_self}?mod=blog&fun=blog_category_list&blog_category_id={$blog.catid}">{$blog.cat}</a></span>{/if}
                <span>{$blog.date}</span><a href='{$php_self}?mod=blog&fun=blog_article_show&blog_id={$blog.id}{if $category_type_blog == 1}&from=blog_date{/if}'>{$constLan._LAN_BLOG_MORE}</a>
            </div>
            {if $smarty.foreach.homeblog.last != true}
                {if $hr == "y"}<img src='upload/update_img/hr.png' />{else}<img src='default/images/hr.gif' />{/if}
            {/if}
        {else}
            <div>
                <p><span>{$constLan._LAN_BLOG_NODATA}</span></p>
            </div>
        {/if}
    {/foreach}
{/if}