Welcome Guest, Not a member yet? Register   Sign In
One view template, multiple views inside it.
#1

[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?
#2

[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
#3

[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




Theme © iAndrew 2016 - Forum software by © MyBB