CodeIgniter Forums
One view template, multiple views inside it. - 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: One view template, multiple views inside it. (/thread-39217.html)



One view template, multiple views inside it. - El Forum - 03-04-2011

[eluser]Steve Moss[/eluser]
Hello, I just downloaded Code Igniter and now I'm learning it. So I already know how to pass data to views and all that. But what I need is create one view that has like multiple views inside it. I've seen some examples with 'header.php', 'footer.php'. But that's not what I need/want for two reasons.
1. I don't like the idea of it. I would rather have one file, for example 'baseView.php'.
2. Header/Footer concept wouldn't work in my case since I need to have something different.

What I would like is to have 'baseView.php' that would look something like this:
Code:
<!DOCTYPE html>
&lt;html&gt;
... (js, css etc...)
<div id="sideBar">
//Dynamic sidebar view here (information like server load, user login etc...)
</div>
<div id="content">
//Content here, items from database if we are logged in and some other stuff...
</div>
...
&lt;/html&gt;

Anyway, I hope you understand what I want to do. The reason for that is that I have (for example) and administration panel, I want the side bar, header, footer stay the same, but I need only content division to change based on what I want (for instance add something to DB or delete something from DB).


Is that possible, and if it is then how?


One view template, multiple views inside it. - El Forum - 03-04-2011

[eluser]InsiteFX[/eluser]
Code:
<!DOCTYPE html>
&lt;html&gt;
... (js, css etc...)
&lt;?php echo your suff here!
<div id="sideBar">
//Dynamic sidebar view here (information like server load, user login etc...)
&lt;?php echo $sidebar;?&gt;
</div>
<div id="content">
//Content here, items from database if we are logged in and some other stuff...
&lt;?php echo $content;?&gt;
</div>
...
&lt;/html&gt;

// when you load the view template just pass a $data with it which you setup all the data.

InsiteFX


One view template, multiple views inside it. - El Forum - 03-04-2011

[eluser]R_Nelson[/eluser]
check out this video
Code:
http://net.tutsplus.com/videos/screencasts/codeigniter-from-scratch-day-6/
about the first 5 mins or so they show you how to do this without having to download an add-on.

i just edited my page to do what i want and it works great