CodeIgniter Forums

Full Version: Loading a div in view.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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>);

El Forum

hi peace you have to do some thing like this.

public function index()
       $data['div1'] = '<div id="xyz">';
        $data['div2'] = '<div id="xyz">';
        $data['div3'] = '<div id="xyz">';

&lt;? echo $div1?&gt;
&lt;? echo $div2?&gt;
&lt;? echo $div3?&gt;

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

El Forum

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

$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