• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
site inside enclosing html

#1
[eluser]Unknown[/eluser]
Hi.

I was wondering, is there a way to place down a markup on every page, regardless of the controller, and than load the views inside that? So, for example I can create a wrapper div for my site, and than load the necessairy views inside that.

#2
[eluser]Pedro Luz[/eluser]
i dont know if i did understand want you want

but you can use a kind of template

Code:
// the view that you want to load
$data["main_content"] = "/foobar_list";

// load the template base and pass the data
$this->load->view("/tpl/template_base", $data);

in the view, the /tpl/template_base.php
Code:
<div class="main-content">
&lt;?php
// loads a view if the $main_content is passed
isset($main_content) ? $this->load->view($main_content) : "";
?&gt;
</div>

and you can do this for has many views as you want
just pass

Code:
$data['navigation'] = 'views/navigation';
$data['banners'] = 'views/banners';
$this->load->view('template_base', $data);

this way you can send multiple views to the template

#3
[eluser]Unknown[/eluser]
Is it concidered bad practice to do this using hooks? so for example to make a pre_controller hook that displays something like "&lt;html&gt;&lt;div id='wrapper'>";
and a post_controler that displays "</div>&lt;/html&gt;"?

p.s. yes, I know there should also be head and body tags, this was just an example.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.