Welcome Guest, Not a member yet? Register   Sign In
Views happening too early
#1

[eluser]Unknown[/eluser]
Within a view file the inc/footer view will frequently (but not always) occur before the <h1> tag. Example view below:

Code:
&lt;?php $this->load->view('inc/header'); ?&gt;
<h1>Hi</h1>
&lt;?php $this->load->view('inc/footer'); ?&gt;

Occurring in both 2.1.2 and 2.1.3.
#2

[eluser]egy_programozo[/eluser]
what's the content of the footer?
#3

[eluser]CroNiX[/eluser]
create a helper or something.

/application/helpers/page_helper.php
Code:
function make_page($content = '')
{
  //load CI instance
  $CI =& get_instance();
  //load header into a variable
  $header = $CI->load->view('inc/header', null, TRUE);
  //load footer into a variable
  $footer = $CI->load->view('inc/footer', null, TRUE);
  //output the header + content + footer
  $CI->output->set_output($header . $content . $footer);  //control/buffer output using CI's output class
}

in your controller:
Code:
//load the helper (autoload is better since you will use it all over)
$this->load->helper('page');

//only get the view for this page, as a variable
$content = $this->load->view('view_for_this_page', $data, TRUE);
// /application/views/view_for_this_page.php = '<h1>Hi</h1>'

//call your helper and pass it the content, and it will insert it between the reusable header/footer.
make_page($content);
#4

[eluser]Unknown[/eluser]
[quote author="CroNiX" date="1350679756"]create a helper or something.

/application/helpers/page_helper.php
Code:
function make_page($content = '')
{
  //load CI instance
  $CI =& get_instance();
  //load header into a variable
  $header = $CI->load->view('inc/header', null, TRUE);
  //load footer into a variable
  $footer = $CI->load->view('inc/footer', null, TRUE);
  //output the header + content + footer
  $CI->output->set_output($header . $content . $footer);  //control/buffer output using CI's output class
}

in your controller:
Code:
//load the helper (autoload is better since you will use it all over)
$this->load->helper('page');

//only get the view for this page, as a variable
$content = $this->load->view('view_for_this_page', $data, TRUE);
// /application/views/view_for_this_page.php = '<h1>Hi</h1>'

//call your helper and pass it the content, and it will insert it between the reusable header/footer.
make_page($content);
[/quote]

Thanks will try this...




Theme © iAndrew 2016 - Forum software by © MyBB