Smarty {foreach} being relocated in template

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
RHF
Forum Members
Forum Members
Posts: 20
Joined: Sun Jan 23, 2011 1:55 am

Smarty {foreach} being relocated in template

Post by RHF »

I have run into a situation which I do not understand. I put the following code in my Content block, and the program works perfectly, displaying the Authors and Titles (from a database) exactly as expected based on the style sheet.

Code: Select all

<table>
<tbody>
<tr><th>Author</th><th>Title</th></tr>
{foreach from=$items item=i}
<tr><td>{$i.author}</td><td class="title">{$i.title}</td></tr>
{/foreach}
</tbody>
</table>
The above code is similar to several examples in the smarty documentation. However, when I return to the Content edit page the code has been modified to the following.

Code: Select all

{foreach from=$items item=i}{/foreach}
<table>
<tbody>
<tr><th>Author</th><th>Title</th></tr>
<tr>
<td>{$i.author}</td>
<td class="title">{$i.title}</td>
</tr>
</tbody>
</table>
Note that the {foreach}{/foreach} tags have been moved to just before the <table>. This also produces the outputs exactly the way I want them, but I do not understand how this can be. Obviously, I am missing something fundamental here and would greatly appreciate some guidance.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: Smarty {foreach} being relocated in template

Post by Dr.CSS »

That type of smarty code does not belong in a content box...
Post Reply

Return to “The Lounge”