September 16, 200818 yr hi , i previously design and program a web site that have a index page that require various modules as needed via switch statement assume that this is my index page so we have <?php require_once('includes/site.config.php'); //in config i have site wide setting , declaring objects , error handling , .... require_once('includes/header.inc.php'); ?> <!-- content , tables , images , etc ... goes here --> in main content center table i have this switch switch($_GET["section"]){ case 'register': require_once('modules/register.php'); break; case 'about': require_once('about.php'); break; case 'users_list': require_once('users_list.php'); break; case 'news' : require_once('modules/news.php'); break; case 'site_policy': require_once('site_policy.php'); break; case 'contact': require_once('modules/contact.php'); break; default: break; } <!-- after htmls include footer file --> <?php include('includes/footer.inc.php');?> now i learn smarty and i like to this web site have a template engine , the problem is i don't know how to assign this functionality to a tpl file plus in many place in the index page i have to add another section and it's just possible with switch for example : i have to require profile module and if this module called by user other modules like news , login, etc .. will be removed . so i use the following line of code : if($_GET['section'] == 'profile'){ //do this and require news or login .etc . }else{ require('path/to/profile.php'); } an screen shot of site structure here i think this task could be done like this $smarty ->assign("section" , $_GET['section'] ) ; //because the $_get super global return array $smarty ->display("index.tpl"); then use {foreach } , {if} and {ifelse} statement to determaind switch but i go thought many search but i can't find any professional programmer do such thing . so please let me know if there is a better solution to still writing entire web application in one file and use smarty with it , without using switch to determine section to require modules . Regards . Mehdi .
Create an account or sign in to comment