Welcome Guest, Not a member yet? Register   Sign In
$this->load->view() and $this->parser->parse() can't permit two calls in the same run
#1

[eluser]Unknown[/eluser]
It is, if you call:

$this->load->view()

and you recall this function in the same execution, only outputs the last call. First call is loosed. Already not is possible store output in a variable, this appear empty.

I tried in the solution of call diferents "output" procedures, like:
$this->parser->parse()

If i call this function two times, fail, and only return the last call.

In this case, i have two methods to parse templates in a same execution, but i need three or more (header, body, footer).

How I can to parse three or more templates in the same execution?

Example:

Code:
function ParsePage()
{
  $header = $this->load->view(header.php);
  $body = $this->load->view(body.php);
  $footer = $this->load->view(footer.php);

  return $header.$body.$footer;
}

Tanks
#2

[eluser]tonanbarbarian[/eluser]
If you want to get the result of the view in a variable then you need to set the 3rd parameter to true

i.e.
Code:
function ParsePage()
{
  $header = $this->load->view(header.php, null, true);
  $body = $this->load->view(body.php, null, true);
  $footer = $this->load->view(footer.php, null, true);

  return $header.$body.$footer;
}

just of note in case you are not aware the 2nd parameter is the data to send to the view. I am setting to null in this example because I do not know if you have any data to send
#3

[eluser]ejangi[/eluser]
You should also be able to do this (according to the documentation):

Code:
function ParsePage()
{
  $this->load->view('header');
  $this->load->view('body');
  $this->load->view('footer');

  return $this->output->get_output();
}
#4

[eluser]Unknown[/eluser]
[quote author="tonanbarbarian" date="1196822891"]If you want to get the result of the view in a variable then you need to set the 3rd parameter to true

i.e.
Code:
function ParsePage()
{
  $header = $this->load->view(header.php, null, true);
  $body = $this->load->view(body.php, null, true);
  $footer = $this->load->view(footer.php, null, true);

  return $header.$body.$footer;
}

just of note in case you are not aware the 2nd parameter is the data to send to the view. I am setting to null in this example because I do not know if you have any data to send[/quote]

Tankyou tonanbarbarian. You solved my problem. It's very easy Smile. Tanks




Theme © iAndrew 2016 - Forum software by © MyBB