+1 vote
783 views
in Programming by Expert (5.9k points)

hello guys can you help me on this, i am writting this

if(empty($_GET[page])) {
 $template="home.tpl";
 $smarty->assign('pagename', ' - Home');
}else {
$page = $_GET["page"];
switch ($page) {
        case "home":
            $template="home.tpl";
             $smarty->assign('pagename', ' - Home');
            break;
        case "contact":
            $template="contact.tpl";
            $smarty->assign('pagename', ' - Contact us');
            break;
        case "verify":
            $template="verify.tpl";
            $smarty->assign('pagename', ' - Verify your account');
            break;
        default:
            $template="404.tpl";
            break;
    }

}

$smarty->assign('sitename', $sitename);
$smarty->display($template);
What if I have "log-in" and "user area" and everything? How can I make them each do their own functions cleanly?
closed

1 Answer

+3 votes
by (1.5k points)
selected by
 
Best answer

you can try this :

<?php $page =(isset($_GET['page'])) ? $_GET['page']: ''; ?>

but how you changing the frontcontroller  you can use :

$content = "";

$page =(isset($_GET['page'])) ? $_GET['page']: '';

// FRONTCONTROLLER
    switch ($page) {
        case 'stack':
            require_once('includes/stack.php');
            $content = getContent();
            break;

        case 'overflow': 
            require_once('includes/overflow.php');
            $content = "overflow....";
            break;

        case default:
               $content = "blalala";
               break;




$smarty->assign('page',$page);
$smarty->assign('content',$content);
$smarty->display('index.htm');
0
by Expert (5.9k points)
Nice explanation... @swag it helped me too thanks !

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated