CodeIgniter Forums
blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: blank page when i try to get $this->load->view into a var with third param on true [SOLVED] (/showthread.php?tid=13091)



blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - El Forum - 11-10-2008

[eluser]meigallodixital[/eluser]
i'm trying to save a view into a var with this code:

Code:
$data['news'] = $this->db->get('news')->result();
$web['content'] = $this->load->view('news',$data,TRUE);
$this->load->view('template',$web);

news view is a foreach loop with echos. But this code gives a blank page. If i omit $data:
Code:
$this->load->view('news','',TRUE)

works, anyone knowns why?

Thanks in advance. Sorry, my english is very bad Smile


blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - El Forum - 11-10-2008

[eluser]John_Betong[/eluser]
 
I reckon the problem could be on any one of your lines of code so suggest inserting this code.
It will show where the data is not appearing:
 

Code:
function _show($data) { // '_' prefix to denote private function to this class

    echo '</pre>';
      print_r($data);
    echo '</pre>';
    echo '<br /><br /><br /><br />';

  }//endfunc  
  

  function index_or_whatever() {

    $data['news'] = $this->db->get('news')->result();
    _show($data['news']);

    $web['content'] = $this->load->view('news',$data,TRUE);
    _show($web['content']);

    _show($web);
    $this->load->view('template',$web);
  }//endfunc
&nbsp;
&nbsp;
&nbsp;


blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - El Forum - 11-11-2008

[eluser]meigallodixital[/eluser]
returns the same blank page, if i do:

Code:
$data['news'] = $this->db->get('news')->result();
$this->load->view('news',$data);

works perfectly. The problem seems $data+true param


blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - El Forum - 11-11-2008

[eluser]meigallodixital[/eluser]
my fault, i have an error in pagination code, sorry Tongue


blank page when i try to get $this->load->view into a var with third param on true [SOLVED] - El Forum - 11-11-2008

[eluser]John_Betong[/eluser]
[quote author="meigallodixital" date="1226417492"]returns the same blank page, if i do:

Code:
$data['news'] = $this->db->get('news')->result();
$this->load->view('news',$data);

works perfectly. The problem seems $data+true param[/quote]
&nbsp;
&nbsp;
If you are trying to use the TRUE parameter to save the contents of a partial view then you must assign the partial view to a variable:
Code:
$data['news'] = $this->db->get('news')->result();
  $partial_view = $this->load->view('news', $data, TRUE);
  echo $partial_view;
&nbsp;
Have you read and understood Views
&nbsp;
&nbsp;