Welcome Guest, Not a member yet? Register   Sign In
Library recall from a Helper issue

[eluser]Feathers And Down[/eluser]
Hi everyone hope someone can help me with this. I try to do my own library (about templates and assets, etc...) and I have found a trouble with this situation: when method controller logic is done, finally it have to output the final result, so I use my library 'library1' to render the page with a method called 'method1', the method calls the $this->ci->load->view( 'view1', $data ); so it load the web page. Inside the web page it have a call to a helper 'helper1' that calls 'method2' from 'library' to add a value in an array that the same 'method1'(from library1) use to the final page. Is something like recursion:

-> 'library1'
-> 'method1'
-> load ci 'view'
-> 'view' call helper 'helper1'
-> 'helper1'
-> call 'method2' from 'library1'

The problem is that when helper call method2, it work for its own values and from the library attributes class, but when then leave the method and start the final render with $this->ci->load->view() (inside library1->method1 called from controller) it doesn't keep helper values added/deleted from its logic.

Please help me with this I will give more info if you want.

controller calls:
public function prueba1( ) {

        $this->load->helper ( 'helper1' );
        $this->load->library( 'libreria1' );

        $this->libreria1->metodo1( 'vista1' );

class Libreria1 {

    private $ci = NULL;
    private $head = array( );

    public function Libreria1( ) {

        $this->ci =& get_instance();

    public function metodo1( $vista ) {

        $this->head[] = 'value_temp'; //this value print fine
        $this->ci->load->view( $vista, array( 'head' => $this->head ) );

    public function metodo2( $archivo ) {

        $this->head[] = $archivo;

function helper1( $archivo ) {

    $CI =& get_instance();
    $CI->libreria1->metodo2( $archivo );  //The library1 recall

helper1( 'archivo' );
    Hola mundo =)

    <?php foreach( $head as $key => $val )
        echo $key. '=' .$val.'<br>'; ?&gt;


I don't know if I make understand me and sorry by my poor english is not my native language.

Messages In This Thread
Library recall from a Helper issue - by El Forum - 12-26-2010, 06:08 PM
Library recall from a Helper issue - by El Forum - 12-26-2010, 07:09 PM

Theme © iAndrew 2016 - Forum software by © MyBB