1 <?php |
1 <?php |
2 require_once(realpath(dirname(__FILE__) . "/../config.php")); |
|
3 |
2 |
4 function renderLayoutWithContentFile($contentFile, $variables = array(), $css=array()) |
3 require_once realpath(dirname(__FILE__).'/../config.php'); |
5 { |
|
6 $contentFileFullPath = TEMPLATES_PATH . "/" . $contentFile; |
|
7 |
4 |
8 // making sure passed in variables are in scope of the template |
5 function renderLayoutWithContentFile($contentFile, $variables = array(), $css = array()) |
9 // each key in the $variables array will become a variable |
6 { |
10 if (count($variables) > 0) { |
7 $contentFileFullPath = TEMPLATES_PATH.'/'.$contentFile; |
11 foreach ($variables as $key => $value) { |
8 |
12 if (strlen($key) > 0) { |
9 // making sure passed in variables are in scope of the template |
13 ${$key} = $value; |
10 // each key in the $variables array will become a variable |
14 } |
11 if (count($variables) > 0) { |
|
12 foreach ($variables as $key => $value) { |
|
13 if (strlen($key) > 0) { |
|
14 ${$key} = $value; |
15 } |
15 } |
16 } |
16 } |
|
17 } |
17 |
18 |
18 require_once(TEMPLATES_PATH . "/header.php"); |
19 require_once TEMPLATES_PATH.'/header.php'; |
19 |
20 |
20 echo "<div id=\"container\">\n" |
21 echo "<div id=\"container\">\n" |
21 . "\t<div id=\"content\">\n"; |
22 ."\t<div id=\"content\">\n"; |
22 |
23 |
23 if (file_exists($contentFileFullPath)) { |
24 if (file_exists($contentFileFullPath)) { |
24 require_once($contentFileFullPath); |
25 require_once $contentFileFullPath; |
25 } else { |
26 } else { |
26 /* |
27 /* |
27 If the file isn't found the error can be handled in lots of ways. |
28 If the file isn't found the error can be handled in lots of ways. |
28 In this case we will just include an error template. |
29 In this case we will just include an error template. |
29 */ |
30 */ |
30 require_once(TEMPLATES_PATH . "/error.php"); |
31 require_once TEMPLATES_PATH.'/error.php'; |
31 } |
32 } |
32 |
33 |
33 // close content div |
34 // close content div |
34 echo "\t</div>\n"; |
35 echo "\t</div>\n"; |
35 |
36 |
36 // close container div |
37 // close container div |
37 echo "</div>\n"; |
38 echo "</div>\n"; |
38 |
39 |
39 require_once(TEMPLATES_PATH . "/footer.php"); |
40 require_once TEMPLATES_PATH.'/footer.php'; |
40 } |
41 } |