So I have reached a certain point in the development of my app where having this folder structure:
views/
includes/{header.php, template.php, footer.php}
home.php
xyz.php
...
and loading the views this way
controller.php
$data['lists'] = $lists;
$data['view'] = 'home';
$this->load->view('includes/template', $data);
template.php
<?php
$this->lang->load('common');
if($view == 'videoPage')
{
$header['title'] = $data['title'].' - XYZ.com ';
$header['description'] = $data['description'];
$header['keywords'] = implode(', ',$data['tags']);
$header['canonical'] = $data['canonical'];
$this->load->view('includes/header', $header);
}
elseif (($view == "searchsPage") || ($view == 'tagsPage'))
{
$header['title'] = $query.' - XYZ.com ';
$this->load->view('includes/header', $header);
}
else
{
$this->load->view('includes/header');
}
?>
<div role="container">
<?php
if ( ! empty($data))
{
$this->load->view($view, $data);
if(($view == 'searchsPage') OR ($view == 'tagsPage')):
?>
...SPECIFIC CODE HERE...
<?php endif;
}
else
{
$this->load->view($view);
}
?>
</div>
<?php $this->load->view('includes/footer'); ?>
and more…
Is starting to get a little bit messy, so I was wondering if is worth it to implement an existing templating library from http://getsparks.org/search (search for “template”) or just do some improving to the one I use? Any other ideas?
I also started implementing library on my own but after a while it got messy and then changed to existing one. Specifically I used Phil Sturgeon’s Library and it’s a good one. The link to the library http://getsparks.org/packages/template/versions/HEAD/show.
Hope this helps.