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

[eluser]Dam1an[/eluser]
[quote author="Samuurai" date="1243016795"]I would also like to see a layout feature.. I've only just started using CI, but it looks like I'll have to include the header and footer at the top and bottom of every view....which isn't very DRY.[/quote]

Have you not tried the MY_Controller approach which was suggested earlier on, or using one of the 3rd party librraies?
#22

[eluser]Samuurai[/eluser]
I like the idea of the MY_Controller approach.. is there a core CI file I should edit?

OO is not (yet) my forte.
#23

[eluser]Dam1an[/eluser]
Take a look in the user guide at thepart on extending core classes (near the bottom)

Basically, you create a controller in your application libraries folder which extends the CI controller, and you then extend this in all you're controllers instead of the CI controller
#24

[eluser]Tom Schlick[/eluser]
guys think about this. Expression Engine has a very powerful templating engine. Its pretty much EE's version of smarty. EllisLab said that anything EE needs CI will get... meaning that when Kaylee is good to become a grown up, CodeIgniter will get a shitload of awesome libraries and helpers including an awesome templating engine that will do all of this.
#25

[eluser]Samuurai[/eluser]
Ahh.. found it.. so I create MY_Controller in the libraries dir: I've done this:
Code:
<?php
class MY_Controller extends Controller
{
    function MY_Controller()
    {
        parent::Controller();
    }
    $this->load->view('header');    
}
?>

But now it's giving me a blank page.. also, how will it know to include all the views and THEN the footer?

(I'm used to rails doing all of this for me ;P)

Thanks for your help!
#26

[eluser]Jagar[/eluser]
I think CI has done more than enough, what they done is just terrific and everyone is talking about it. I know everyone has different needs in CI, but if you think about it, it has everything to make a powerful web site.
#27

[eluser]Samuurai[/eluser]
[quote author="Jagar" date="1243020628"]I think CI has done more than enough, what they done is just terrific and everyone is talking about it. I know everyone has different needs in CI, but if you think about it, it has everything to make a powerful web site.[/quote]

I agree, CI looks good so far (only been using it a day!)

How do you handle the headers and footers? Do you load() them in each funtion in each controller?
#28

[eluser]Dam1an[/eluser]
Everyone has their own way of dealing with headers/footers

Some load them manually each time
Some use a template librray
Some create their own light weight template engine
And most use a 2 level layout

With the last options, which is probably what you'll want, is where you have your template as a single file, with a place to either load the content as a view, or echo the content as a string
#29

[eluser]Jagar[/eluser]
For my site, since I use smarty, I use the include function in smarty in every page, and it works great! you can also use <?php include('path/to/header/or/footer')?>, in order to give every site a title, you could use
Code:
<title><?=$title?>
and then in your controller index, you could do something like:
Code:
function index(){
$data['title'] = "SIte title";

$this->load->view('viewname',$data);

}

There are other ways of doing it though.
#30

[eluser]Phil Sturgeon[/eluser]
Instead of starting a thread asking "what is wrong with the CI team" and maintainig a bad attitude throughout, why not try typing "CodeIgniter Layout Library" into Google, search the wiki or search the forums.

In 5 seconds I found one perfect for you as a Rails convert: Ocular Layout Library.

Look in my sig, you just found a second.

Look in Colin's sig, you just found a third! ;-)




Theme © iAndrew 2016 - Forum software by © MyBB