CodeIgniter Forums
Modular Layouting - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Modular Layouting (/thread-2462.html)



Modular Layouting - El Forum - 08-07-2007

[eluser]Martin Penev[/eluser]
Hi there,

I'm programming the backend of a snowboard community-like site for a friend.

There's gonna be a news and a gallery module. I'm going to use CI for as my basic framework and I've dugged into the user guide a lot and tried a few things out. Works excellent.

In order to keep a very high degree of modularity, i'd like to have split everything to modules as far as it's possible. So basically, I'd like to split the HTML output into 2 main regions: header and body. Simple. I wanted to use the output class to manually tell the framework what and when something should be output.

I tried a code like this:

Code:
$data['qNewsTypes'] = $this->news_model->getNewsTypes();            
$strHTMLBody = $this->load->view('news/news_add', $data);
$this->output->set_output($strHTMLBody);
$this->output->_display();

Simply put: First there's gonna be everything that should be within a header, then comes the body and finally everythings gonna be output.

But somehow the code above doesn't work. Maybe it's because I clearly lack experience in CI, so I'm asking of a little help Smile

What's a better solution?

Thanks for your help in advance!


Modular Layouting - El Forum - 08-07-2007

[eluser]gunter[/eluser]
hm, I never used the output class like this, but I think, in this case it has to look like this:
Code:
$strHTMLBody = $this->load->view('news/news_add', $data,TRUE);

remember: $this->load->view('file_name', $data, true/false) without the third argument the $this->load->view() does not return the view, but sends the view to the browser and if needed you can get this view in the output class with: $string = $this->output->get_output();


Modular Layouting - El Forum - 08-07-2007

[eluser]Phil Sturgeon[/eluser]
Thats not gonna work for your very well. Check out the blog tutorial video and use almost exactly the same code as that. News = Blog


Modular Layouting - El Forum - 08-07-2007

[eluser]Martin Penev[/eluser]
@thepyromaniac:

Which one is not going to work? The solution suggested by "gunter"?

I'm generally trying to avoid using repetetive code, I want to specify a template that should be used from many places, but should be written only once.