• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Would like to condense some code.

#10
[eluser]Samuurai[/eluser]
Thanks!
I think on my next site, I'll use the $this->data approach. I've used $data->variable SOO much on this site, I just wanna stay with this standard.

It doesn't seem to be working though..

here are the relevant functions:
Code:
function index()
    {
        $this->load->library('Contact_logic');
    $data->title = "Contact RaceDayStaff.com";
        $data->heading = "Contact RaceDayStaff.com";

        if($this->input->post('submit'))
        {
            $this->_do_contact();
        }
        else
        {
            $this->_populate_contact();
        }

        
        $this->load->view('header', $data); // a var_dump here shows only title and heading are set.
        $this->load->view('contact', $data);
        $this->load->view('footer', $data);
    }
And this:
Code:
function _populate_contact()
    {
        global $data; // Is this the right place to set it?
        if($this->userlib->logged_in())
        {
            $this->load->model('User_model', 'user_m');
            $userid = $this->session->userdata('userid');
            $result = $this->user_m->name_and_email($userid);
            ($this->input->post('name')) ? $data->name = $this->input->post('name') : $data->name = $result['name'];
            ($this->input->post('email')) ? $data->email = $this->input->post('email') : $data->email = $result['email'];
        }
        else
        {
            ($this->input->post('name')) ? $data->name = $this->input->post('name') : $data->name = '';
            ($this->input->post('email')) ? $data->email = $this->input->post('email') : $data->email = '';
            ($this->input->post('subject')) ? $data->subject = $this->input->post('subject') : $data->subject = '';
            ($this->input->post('text')) ? $data->text = $this->input->post('text') : $data->text = '';
        }
    }


Messages In This Thread
Would like to condense some code. - by El Forum - 09-29-2009, 10:29 AM
Would like to condense some code. - by El Forum - 10-01-2009, 08:53 AM
Would like to condense some code. - by El Forum - 10-02-2009, 10:16 AM
Would like to condense some code. - by El Forum - 10-08-2009, 05:50 AM
Would like to condense some code. - by El Forum - 10-08-2009, 06:10 AM
Would like to condense some code. - by El Forum - 10-08-2009, 07:01 AM
Would like to condense some code. - by El Forum - 10-08-2009, 08:30 AM
Would like to condense some code. - by El Forum - 10-09-2009, 06:42 AM
Would like to condense some code. - by El Forum - 10-09-2009, 09:35 AM
Would like to condense some code. - by El Forum - 10-09-2009, 12:27 PM
Would like to condense some code. - by El Forum - 10-09-2009, 01:19 PM
Would like to condense some code. - by El Forum - 10-09-2009, 02:51 PM
Would like to condense some code. - by El Forum - 10-09-2009, 05:41 PM
Would like to condense some code. - by El Forum - 10-09-2009, 05:44 PM
Would like to condense some code. - by El Forum - 10-11-2009, 12:37 PM
Would like to condense some code. - by El Forum - 10-11-2009, 12:47 PM
Would like to condense some code. - by El Forum - 10-11-2009, 02:58 PM
Would like to condense some code. - by El Forum - 10-13-2009, 08:31 AM
Would like to condense some code. - by El Forum - 10-14-2009, 10:02 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.