[eluser]allibubba[/eluser]
some great ideas in here, i'm especially interested in the Ocular Layout Library... Anybody have any experience using it?
here's what i've been using for my presentation layer, would be great to get some feedback on this too.
my controller:
Code:
function index(){
# Set frame class (for css)
$data['frameClass'] = 'admin home';
# Files to include
$data['header'] = "admin.header.php";
$data['primary'] = "admin_home.php";
$data['footer'] = "admin.footer.php";
# Load Views
$this->layout->fullLayout($data);
}
my model (layout.php):
Code:
function fullLayout($data){
$this->load->view('full.layout.php', $data);
}
and my view (full.layout.php):
Code:
<?php
if(isset($primary)) $primary = (get_file_info('./system/application/views/'.$primary))? $primary : null;
if(isset($header)) $header = (get_file_info('./system/application/views/'.$header))? $header : null;
if(isset($footer)) $footer = (get_file_info('./system/application/views/'.$footer))? $footer : null;
#defaults
$title = (isset($title)) ? $title : 'default title';
$frameClass = (isset($frameClass))? $frameClass : 'default';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML etc...">
<html >
<head></head>
<body>
<!-- NOTE: FRAME -->
<div id="frame" class="<?=$frameClass ?>">
<!-- NOTE: HEADER -->
<div id="header">
<?php (isset($header))? include($header) : null; ?>
</div>
<!-- NOTE: PRIMARY -->
<div id="primary">
<?php (isset($primary))? include($primary) : null; ?>
</div>
<!-- NOTE: FOOTER -->
<div class="clear"> </div>
<div id="footer">
<?php (isset($footer))? include($footer) : null; ?>
</div>
</div>
</body>
</html>
this all works fairly well for me and allows me to use different layouts like:
Code:
$this->layout->fullLayout($data);
or
$this->layout->adminLayout($data);
but...
for each controller i have to set header, primary, secondary, footer... granted i could probably just pass in my content (primary) and have a default header/footer, but this allows more control over my views.
anyway this has been working for me, maybe someone has some pointers for improving this structure?
thanks