Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

using smarty in modular web development

Featured Replies

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.