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

[eluser]Sinclair[/eluser]
Problem solved... what a newbie that I'am in OOP..

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', 'E-mail', 'trim|required|valid_email');
        
        if($this->form_validation->run() == FALSE)
        {
            //Se as validações não estiverem bem, fica na mesma página. Aqui defino as function name, title e resulttemp da 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 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"
        }
        else
        {
            //Se as validações estiverem correctas vai para a página seguinte
            $this->load->view ('common/template_view', $this->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"
        
                
    }
      
  
      
}

?>

It is working now.

Best Regards,


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