Welcome Guest, Not a member yet? Register   Sign In
Code Igniter noob :)
#15

[eluser]Total Shop UK[/eluser]
In short there are two main file for the template, top and bottom.

Top contains
Banner, Top Navigation, Left Side

Bottom contains
Right Side, Bottom Navigation, Footer

The dynamic content goes in the middle.
Code:
<?php if (!isset($meta)) $meta=''; echo modules::run('_main/top',$meta); ?>
[content here]
<?php echo modules::run('_main/bottom'); ?>

Every data request uses Ajax - Login Example
Code:
function login(){
    var username = URLEncode(document.getElementById('username').value);
    var password = URLEncode(document.getElementById('password').value);
    var poststr = 'username='+username+'&password;='+password;
    ajax('/_ajax/login', 'login_status', poststr, 'POST', '', check);
}
function check(){
    var check = document.getElementById('login_status')[removed];
    if (check==1){
        document.getElementById('login_box').style.display="none";
        parent.location="/";
    }else{
        document.getElementById('login_check').className="error";
        document.getElementById('login_check')[removed]="Invalid Login!";
    }
}

Controller _ajax
Code:
function login(){
    $data = array();
    if ($this->input->post('username')!='' && $this->input->post('password')!=''){
        $user = $this->db->escape($this->input->post('username'));
        $pass = $this->db->escape($this->input->post('password'));
        $query = $this->db->query("SELECT user_id, user_level FROM users WHERE user_username=$user AND user_password=$pass AND user_active=1");
        if ($query->num_rows()>0){
            foreach ($query->result() as $key => $row){
                $id     = $row->user_id;
                $level    = $row->user_level;
            }
            $this->session->set_userdata('user_id', $id);
            $this->session->set_userdata('user_level', $level);
            $data['msg'] = 1;
        }else{
            $data['msg'] = 0;
        }
    }else{
        $data['msg'] = 0;
    }
    $this->load->view('_ajax/_blank.php',$data);
}

Hope this helps a little.


Messages In This Thread
Code Igniter noob :) - by El Forum - 04-21-2010, 07:39 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 07:47 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 07:51 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 08:32 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 08:35 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 08:48 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 08:52 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 08:58 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 10:42 AM
Code Igniter noob :) - by El Forum - 04-21-2010, 12:48 PM
Code Igniter noob :) - by El Forum - 04-21-2010, 01:11 PM
Code Igniter noob :) - by El Forum - 04-22-2010, 01:55 AM
Code Igniter noob :) - by El Forum - 04-22-2010, 02:00 AM
Code Igniter noob :) - by El Forum - 04-22-2010, 03:01 AM
Code Igniter noob :) - by El Forum - 04-22-2010, 03:20 AM
Code Igniter noob :) - by El Forum - 04-26-2010, 03:47 AM
Code Igniter noob :) - by El Forum - 04-26-2010, 03:58 AM
Code Igniter noob :) - by El Forum - 04-26-2010, 05:19 AM
Code Igniter noob :) - by El Forum - 04-26-2010, 06:09 AM
Code Igniter noob :) - by El Forum - 04-26-2010, 02:21 PM
Code Igniter noob :) - by El Forum - 04-28-2010, 03:58 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 04:36 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 05:08 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 05:43 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 08:54 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 10:44 AM
Code Igniter noob :) - by El Forum - 04-28-2010, 04:28 PM
Code Igniter noob :) - by El Forum - 04-29-2010, 01:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB