Welcome Guest, Not a member yet? Register   Sign In
Whi CI doesn't have Layouts implemented?
#31

[eluser]Dam1an[/eluser]
I wanted to have a look at yours Phil, but it seems to take me to the edit sig page (mine, not yours) :-S Google it is (not that I need a layout library as I have my own light weight implementation, just curious, especially as its hiding from me... always want what I can't have)
#32

[eluser]Phil Sturgeon[/eluser]
Ha! I was updating the link and hit the wrong button on my TinyURL extension. Updated.
#33

[eluser]Dam1an[/eluser]
I'd already found it using Google Smile (Well, I found it on the Wiki)
#34

[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...">
&lt;html &gt;
&lt;head&gt;&lt;/head>
&lt;body&gt;
&lt;!-- NOTE: FRAME --&gt;
<div id="frame" class="&lt;?=$frameClass ?&gt;">
    &lt;!-- NOTE: HEADER --&gt;
    <div id="header">
        &lt;?php (isset($header))? include($header) : null; ?&gt;
    </div>
    &lt;!-- NOTE: PRIMARY --&gt;
    <div id="primary">
        &lt;?php (isset($primary))? include($primary) : null; ?&gt;
    </div>
    &lt;!-- NOTE: FOOTER --&gt;
    <div class="clear">&nbsp;</div>
    <div id="footer">
        &lt;?php (isset($footer))? include($footer) : null; ?&gt;
    </div>
</div>
&lt;/body&gt;
&lt;/html&gt;

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
#35

[eluser]Colin Williams[/eluser]
Why is your model messing with views?
#36

[eluser]Dam1an[/eluser]
I think you want this is a library, and you could always set a default header/footer, but if you specify one, it will use that one instead
#37

[eluser]allibubba[/eluser]
thanks Dam1an,

i'll look into converting into a library, that makes more sense than having it in the model anyway.




Theme © iAndrew 2016 - Forum software by © MyBB