Welcome Guest, Not a member yet? Register   Sign In
blank page when i try to get $this->load->view into a var with third param on true [SOLVED]
#1

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

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

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB