Browse files

Moved template files into a subdir page. Base template now uses a dir…

… path base to it from the library to make it more dynamic
  • Loading branch information...
1 parent 5ed4920 commit 022119793a2a5f4e8a7804128a376a0754009909 Ollie Rattue committed Dec 5, 2011
View
13 web/application/libraries/template.php
@@ -22,6 +22,7 @@ class Template {
var $body_id = NULL;
var $body_class = NULL;
var $page_title;
+ var $template_directory = 'templates/page';
var $template_name = 'default';
function Template()
@@ -90,23 +91,25 @@ function build_page($path = NULL, $data = array())
$data['page_title'] = " - {$this->page_title}";
$data['meta_keywords'] = $this->meta_keywords;
$data['meta_description'] = $this->meta_description;
-
+
if (is_array($path))
{
$path = $path[0]; // arrays of view files are not supported yet
}
@list($controller) = explode("/", substr($path, 0));
-
- $this->CI->load->vars($data);
-
+
// Auto-set admin template based on the controller
if ($controller == 'admin')
{
$this->template_name = 'admin';
}
- $this->CI->load->view("templates/{$this->template_name}/base");
+ $data['template_directory'] = $this->template_directory;
+ $data['template_name'] = $this->template_name;
+
+ $this->CI->load->vars($data);
+ $this->CI->load->view("{$this->template_directory}/{$this->template_name}/base");
}
// --------------------------------------------------------------------
View
8 ...lication/views/templates/default/base.php → ...ion/views/templates/page/default/base.php
@@ -6,10 +6,10 @@
<?php /* Consider adding a manifest.appcache: h5bp.com/d/Offline */ ?>
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<?php
-$this->load->view('templates/default/head');
+$this->load->view("{$template_directory}/{$template_name}/head");
echo generate_body_tag($body_id, $body_class)."\n\t";
echo '<div class="container clearfix">' . "\n\t";
-$this->load->view('templates/default/header');
+$this->load->view("{$template_directory}/{$template_name}/header");
echo '<div id="main" role="main" class="clearfix">' . "\n\t";
if (is_array($path))
@@ -25,9 +25,9 @@
}
echo '</div>' . "\n";
-$this->load->view('templates/default/footer');
+$this->load->view("{$template_directory}/{$template_name}/footer");
echo '</div>' . "\n";
-$this->load->view('templates/default/footer_js');
+$this->load->view("{$template_directory}/{$template_name}/footer_js");
echo '</body>' . "\n";
?>
</html>
View
0 ...cation/views/templates/default/footer.php → ...n/views/templates/page/default/footer.php
File renamed without changes.
View
0 ...ion/views/templates/default/footer_js.php → ...iews/templates/page/default/footer_js.php
File renamed without changes.
View
0 ...lication/views/templates/default/head.php → ...ion/views/templates/page/default/head.php
File renamed without changes.
View
0 ...cation/views/templates/default/header.php → ...n/views/templates/page/default/header.php
File renamed without changes.

0 comments on commit 0221197

Please sign in to comment.