CodeIgniter Forums
Creating dynamic layout - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Creating dynamic layout (/thread-33136.html)



Creating dynamic layout - El Forum - 08-16-2010

[eluser]Ficoder[/eluser]
Hi!
I have a question about creating dynamic layout.
Situation is this:

application/controllers/test.php
Code:
<?php
function DoYourThing()
{
  $data['main_content'] = 'TestView'; //Let's include TestView.php from /views
  $this->load->view('layout/site', $data);
}
?>

application/views/layout/site.php
Code:
<?php $this->load->view('layout/header'); ?>

<?php $this->load->view($main_content); ?>

<?php $this->load->view('layout/footer'); ?>

application/views/TestView.php
This is test.


This works as it should, but... When i modified TankAuth's auth.php file to include all views inside my layout, i couldn't figure out how to solve this.

There is line: $this->load->view('auth/general_message', array('message' => $message));

And my modified line would be:
$data['main_content'] = 'auth/general_message';
$this->load->view('layout/site', $data);

But how i can pass that array('message' => $message) as in the original file?


Creating dynamic layout - El Forum - 08-17-2010

[eluser]noname11[/eluser]
Ficoder, look at this post:
http://ellislab.com/forums/viewthread/57902/
Hope it will be helpful to you.


Creating dynamic layout - El Forum - 08-17-2010

[eluser]Ficoder[/eluser]
Big thanks!

This was exactly what i wanted: http://codeigniter.com/wiki/layout_library/ Works like charm.