09-25-2007, 10:34 AM
|
#9 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Salathe is spot on. Template files can be really extensive. However, to extend onto our simple template class, I would add the following code to store page states as well. That way you can have like so:
- profile.default.php: Page to allow members to edit their profile
- profile.complete.php: Page to inform users that profile update is complete
- profile.error.php: Page to pull users back when they've left a required field empty
We create our views folder and then inside there we have our individual page folders, and then in our individual page folders we have the page states as listed above.
PHP Code:
<?php
define('VIEW_DEFAULT', 'default'); define('VIEW_COMPLETE', 'complete'); define('VIEW_ERROR', 'error');
class Template { public function display($szView, $szState = VIEW_DEFAULT) { $szPage = 'views/' . $szView . '/' . $szView . '.' . $szState . '.php'; if (file_exists($szPage)) { include $szPage; } } }
$tpl = new Template; $tpl->display('example', VIEW_COMPLETE); // views/example/example.complete.php
?>
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|