Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter View and echo

I have a function that which process the side bar of a web page in codeigniter.

as follows :

function process_sidebar()
{
$this->load->view("first_access"); // ------------(1)
$this->load->view("second_access");// --------------(2)
echo "Here i want to show some data after loading view second_access"; //pls note here --(3)

$this->load->view("third_access"); // --------------------(4)
$this->load->view("fourth_access"); //-------------------------(5)

}

Please check the order numbers,but the problem is codeigniter not keeping the order.

it rendering the view last and showing the echo part first..

how can i overcome this ?

Thank you.

like image 971
Red Avatar asked Feb 04 '12 05:02

Red


1 Answers

You'll want to append_output() rather than echo:

<?php
function process_sidebar()
{
    $this->load->view("first_access"); // ------------(1)
    $this->load->view("second_access");// --------------(2)
    $this->output->append_output("Here i want to show some data after loading view second_access"); //pls note here --(3)
    $this->load->view("third_access"); // --------------------(4)
    $this->load->view("fourth_access"); //-------------------------(5)
}
like image 150
landons Avatar answered Sep 18 '22 06:09

landons