Do it all in one page, that's ways faster and cleaner than using 3 different files.
I'll try to explain how i did it:
To place a loop in the template, i used the {for} keyword, like this:
smarty Code:
{for loop=$var name=i}
<!-- content here -->
{/for}
where $var was the array to loop over. I is the name of the variable which will hold the current array-index. I had some additional parameters, such as "start" and "end", but i'll leave them out atm.
I used a regex to get the {for ....} declaration, and grab the value of the "loop" and "name" parameter (note: the regex below is not the one i'm using in my engine):
I used
preg_match_all to get all for-loop declarations in the template, and then looped over them to convert them to php. So in the end you get something like this:
Next i store the file in a different directory, but as php file. This way i only have to compile the template once in order to get it working for everyone. You will have to change your script so it will check if the template is allready compiled first, if so, you jsut have to load the php page, and set a value to the $var variable. Or: instead of replacing the tags in the template document, you just declare the tags in your script, and run the compiled template (hope you can follow, i'm not very good at explaining sometimes

).
Here's an example of what a compiled template looks like after running it through my engine:
i'm using classes as well, so that's where the $this->TPL_VARS comes from. That field holds all data that needs to be displayed within the template.
and this is what it looked like before compiling:
smarty Code:
{for loop=$var name=i}
<b>{$var[i]}</b><br/>
{/for}
You see that you will have to convert the variable you're using within the for loop as well. Don't forget this, or it will never work

(i forgot, and it took me about a day to find out what exactly wasn't working)
Hope this helps you more than it confuses you

cheers