Welcome Guest, Not a member yet? Register   Sign In
Loading a div in view.
#1

[eluser]Unknown[/eluser]
while loading a view is it possible to load only a small part of a page.
Say i have a template page that contains 5 div's and i just want to load a single div(id=xyz).

In my controller i like to do something like this

public function index()
{
$this->load->view(<div id=xyz>);
}
#2

[eluser]umefarooq[/eluser]
hi peace you have to do some thing like this.

controller
Code:
public function index()
  {
       $data['div1'] = '<div id="xyz">';
        $data['div2'] = '<div id="xyz">';
        $data['div3'] = '<div id="xyz">';
      $this->load->view('your_view_name',$data);
  }

view
Code:
&lt;html&gt;
&lt;body&gt;
&lt;? echo $div1?&gt;
&lt;? echo $div2?&gt;
&lt;? echo $div3?&gt;
&lt;/body&gt;
</htm>

its will work fine. you have to pass array of variables to view. check user guide also.
#3

[eluser]Colin Williams[/eluser]
Or, fetch a smaller view and send it to the main one

Code:
$data['part'] = $this->load->view('part', '', TRUE);
// Use TRUE to capture result and not render it

$this->load->view('page', $data);
// There is now a $part var in the page.php view the holds the rendered contents of the part.php view




Theme © iAndrew 2016 - Forum software by © MyBB