Вопрос

I have Smarty 3.1 working with my website for JUST Index.php.

Now, how would I add on and make a contact page?

1) Make contact.php and make a whole new template?

2) Make it index.php?page=contact ??

3) Make contact.php and use the template and pass variables to template making it show contact stuff....?

Это было полезно?

Решение

2) Make it index.php?page=contact

The better approach is use a centralized system. You could get the page value and load the appropriate template.

For example:

switch ($page) {
    case "home":
        $template="home.tpl";
        break;
    case "contect":
        $template="contact.tpl";
        break;
    default:
        $template="404.tpl";
        break;
}

$smarty->display($template);
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top