index.php
<?php require_once('Smarty/Smarty.class.php'); $smarty = new Smarty; $smarty->template_dir = "Style/"; $smarty->compile_dir = 'Smartownia/templates_c/'; $smarty->config_dir = 'Smartownia/configs/'; $smarty->cache_dir = 'Smartownia/cache/'; switch($_GET[act]) { case 'glowna' : $strona = 'glowna'; break; case 'aktualnosci' : $strona = 'aktualnosci'; break; default : $strona = 'glowna'; break; } } else { $strona = 'glowna'; } $smarty->assign('strona', $strona); $smarty->display('index.tpl'); ?>
index.tpl
<?php <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-2"> <title>Insane </head> <body> <table border="1" width="800"> <tr> <td colspan="2">LOGO </tr> <tr> <td width="650"> {if $strona eq "glowna"} {elseif $strona eq "aktualnosci"} {/if} </td> </tr> </table> </body> </html> ?>
aktualnosci.php
<?php require_once('Smarty/Smarty.class.php'); $smarty = new Smarty; $smarty->template_dir = "Style/"; $smarty->compile_dir = 'Smartownia/templates_c/'; $smarty->config_dir = 'Smartownia/configs/'; $smarty->cache_dir = 'Smartownia/cache/'; $smarty->assign('imie', $imie); $smarty->display('aktualnosci.tpl'); ?>
aktualnosci.tpl
<?php <p>TUTAJ MOŻEMY ZAMIEścić AKTUALNOŚCI</p><br /> {$imie} wypelnij ponizszy formularz<br /> <form method="post" action="index.php?act=aktualnosci"> <input type="text" name="imie"> <input type="submit"> </form> {/if} ?>
To wszystko oczywiście to są ćwiczenie do nauki. To nie pod żadną stronę.
Edit by in5ane:
Nie dopisałem, że właśnie tutaj w tych "aktualnosciach" już to zacząłem kombinować, ale nie działa. Zawsze jest pusta strona. Nie pokazuje wogóle formularza. A jak poprawiłem trochę inaczej sobie IF'y to wtedy przeładowuje stronę i pokazuje nadal formularz zamiast imię. Po przerobieniu IF'y były na zasadzie {if $imie eq ''} {elseif $imie neq ''}.