Welcome Guest, Not a member yet? Register   Sign In
Display the view in a specified <div>
#1

[eluser]Filip_vh[/eluser]
Hello,

As the topic says, I'm wondering wether it would be possible to have a general lay out where I can specify everything on my site that doesn't change over all pages (such as the menu). This way I wouldn't have to paste the entire code there (see below).

Code:
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;/title>
&lt;/head&gt;
&lt;body&gt;
....
<div id="view">

....actual stuff that the view should show here....

</div>
...
&lt;/body&gt;
&lt;/html&gt;

If I could just have it put inside the correct div. My views would be a lot easier to manage and maintain.

I'm sorry of this is a silly question but the video tutorials don't mention any of this (AFAIK) and I couldn't immediately find something like it in the user guide (though I have to admit I didn't completely search them. Just a first glance but nothing seemed to fit what I was looking for ... 8-/ ).

I hope somebody can give me a push in the right direction.


Cheers


Filip
#2

[eluser]fesweb[/eluser]
I just came to a solution for this yesterday, and posted it in this thread.

I think that's what you're looking for.
#3

[eluser]Sarfaraz Momin[/eluser]
You can achieve it by doing something like this.
controller
Code:
$data['divcontent'] = $this->load->view('divcontent','',true)
$this->load->view('commonpage',$data)

view
Code:
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;&lt;/title>
&lt;/head&gt;
&lt;body&gt;
<div id="view">

&lt;?= $divcontent ?&gt;

</div>
&lt;/body&gt;
&lt;/html&gt;

Hope this helps.

Have a good day !!!




Theme © iAndrew 2016 - Forum software by © MyBB