0

I basically have this code:

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>{$root.page.contentgroup.Directory[0]}</td>
<td>{$root.page.contentgroup.Title[0]}</td>
<td>{$root.page.contentgroup.Description[0]}</td>
</tr>
</table>

I would love to add a button, and when I click it, it generate 3 txt files. When the script generate the txt file, it should locate them according to {$root.page.contentgroup.Directory[0]}. For example:

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>mydirectory</td> {**directory.txt**}
<td>mytitle</td> {**title.txt**}
<td>mydescription</td> {**description.txt**}
</tr> 
</table>
[SUBMIT]

When I click submit, the script generate the 3 txt files and locate them on

mysite/folder/{$root.page.contentgroup.Directory[0]}/directory.txt
mysite/folder/{$root.page.contentgroup.Directory[0]}/title.txt
mysite/folder/{$root.page.contentgroup.Directory[0]}/description.txt

what is the better way to do it? I can use only smarty functions (((

Thank you

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
user3848253
  • 11
  • 1
  • 3

1 Answers1

0

This must be implemented with php. Smarty is a template engine, and must be used only for presentation. (Or even better -my opinion- don't use a template engine at all. An opinion based question on this here.)

If you want badly to do things really bad, you may use the {php} tag that allows php code to be embeded inside smarty's .tpl files.

{php}
   // including a php script directly from the template.
   include('/path/to/your_file_generation_script.php');
{/php}

http://www.smarty.net/docsv2/en/language.function.php.tpl

Community
  • 1
  • 1
Sharky
  • 6,154
  • 3
  • 39
  • 72