Welcome Guest, Not a member yet? Register   Sign In
How to call a method in the same class?
#12

[eluser]laytone[/eluser]
After the page goes to the user the data that was in $data_template is gone erased poof no longer exists.... It wont be there its gone.

1. Function index() is run
2. The page is sent to the user and everything no longer exists
3. The user submits the form to function2 and everything is brand new the variables from when you ran index() no longer exists.
4. Function 2 runs and the page is sent back to the user and no longer exists.
5. The user makes another request and everything is brand new again!

If you call function2 from function1 then they will both run.. but that wont do you any good.

[quote author="Sinclair" date="1266367859"]Hi,

I have done it, but is not working...

The data_template variable have the same name in Index() and in Subscricaopasso2(). How can I call it in the correct way?

Here is the code:

Code:
<?php

class Newsletter extends Controller {
    
    public $data_template;
      
    function Newsletter()
    {
        parent::Controller();
        
        $this->load->helper('form');
        $this->load->helper('url');
        $this->load->helper('array');
        $this->load->helper('my_addjsfile_helper');
        $this->load->helper('my_addbodytag_helper');
        $this->load->model('Template_model');
    }
      
    function index()  
    {  
                
        
        #BEGIN PASSAGENS P O TEMPLATE PRINCIPAL
        # Aqui coloco as configuracoes estáticas da funcao
        $function_name = 'newsletter_index'; # [nomedocontroller_nomedafuncao]
        # Aqui coloco as configuracoes dinamicas da funcao
        $title = 'Newsletter'; # Aqui defino o título da página
        #Aqui passo as zonas para o template principal
        $resultTemp = $this->Template_model->getZonasComAnunciosActivos();
        #END PASSAGENS P O TEMPLATE PRINCIPAL
        
                
        
        # Neste bloco defino a passagem de variáveis para a view
        #$this->data_view['result'] = $this->Tag_model->getTodasAsTags();
        #$this->data_view['result2'] = $this->Tag_model->getTodasAsTagsCloud();
        $this->data_view['result2'] = null;
                
        
        # Neste bloco defino a passagem de variáveis para o template_view
        $this->data_template['function_name'] = $function_name;
        $this->data_template['title'] = $title;
        $this->data_template['resultTemp'] = $resultTemp;
        
        
        $this->load->view ('common/template_view', $this->data_template); # Aqui leio o template comum em "common/template_view.php"        
    }    
      
    
    function subscricaopasso2()  
    {  
        $this->load->library('form_validation');
        
        #BEGIN PASSAGENS P O TEMPLATE PRINCIPAL
        # Aqui coloco as configuracoes estáticas da funcao
        $function_name = 'newsletter_subscricaopasso2'; # [nomedocontroller_nomedafuncao]
        # Aqui coloco as configuracoes dinamicas da funcao
        $title = 'Subscrição da Newsletter, Passo 2'; # Aqui defino o título da página
        #Aqui passo as zonas para o template principal
        $resultTemp = $this->Template_model->getZonasComAnunciosActivos();
        #END PASSAGENS P O TEMPLATE PRINCIPAL
        
        
        
        
        # Neste bloco defino a passagem de variáveis para a view
        #$this->data_view['result'] = $this->Tag_model->getTodasAsTags();
        #$this->data_view['result2'] = $this->Tag_model->getTodasAsTagsCloud();
        $this->data_view['result2'] = null;
                
        
        
        # Neste bloco defino a passagem de variáveis para o template_view
        $this->data_template['function_name'] = $function_name;
        $this->data_template['title'] = $title;
        $this->data_template['resultTemp'] = $resultTemp;
        
        
        # Neste bloco faço as validações
        $this->form_validation->set_rules('email', 'Email Address', 'trim|required|valid_email');
        
        if($this->form_validation->run() == FALSE)
        {
            $this->load->view ('common/template_view', Newsletter::index()->data_template); # Aqui leio o template comum em "common/template_view.php"
            #$this->load->view ('common/template_view', $this->data_template); # Aqui leio o template comum em "common/template_view.php"
        }
        else
        {
            null;
        }        
                
    }
      
  
      
}

?>



Best Regards,[/quote]


Messages In This Thread
How to call a method in the same class? - by El Forum - 02-16-2010, 12:16 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:21 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:22 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:25 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:27 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:37 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:39 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:50 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 12:53 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 01:01 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 02:15 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 02:23 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 04:56 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 05:43 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 06:02 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 06:27 PM
How to call a method in the same class? - by El Forum - 02-16-2010, 08:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB