Welcome Guest, Not a member yet? Register   Sign In
Modular Extensions - HMVC _remap methods help
#1

[eluser]Andy78[/eluser]
Before We start please take into consideration that I am a noob to CI and only a recent graduate programmer so I still get confused by object orientated concepts from time to time!

So far im set-up and running with CI2, Modular Extensions - HMVC and ion-auth as a working module.

I plan to split site up into an a user facing frontend and admin backend so I have my main frontend and backend controllers and views in the normal CI controllers and views folders not in modules. I only want my widgets and partial views as modules. Make sense?

This is working so far and I can all the ion-auth login as a widget in my side bar as follows:
Code:
<!-- Begin Right Column -->
         <div id="rightcolumn">
             <div id="right-inner">
            &lt;?php echo modules::run('auth/auth/login');?&gt;
             </div>          
        
         </div>
         &lt;!-- End Right Column --&gt;


In the Modular Extensions - HMVC wiki it says
Quote:If you add the _remap() method to your controllers you can prevent unwanted access to them and redirect or flag an error as you like

I don't want people to be able to access the login widget directly so I need a remap() method but how do I flag an error using this method?

To be more specific the login method in ion-auth has form validation rules how do I flag these in the remap() method and have them display in the in widget view of the login rather than it trying to redirect me to the direct view.

I really need an example to help me understand exactly what's going on.
#2

[eluser]Andy78[/eluser]
To clarify what's going on here is the login method that's being loaded as a partial view by &lt;?php echo modules::run('auth/auth/login');?&gt;.
Code:
function login()
    {
        $this->data['title'] = "Login";
        
        
        //validate form input
        $this->form_validation->set_rules('username', 'Username', 'required');
        $this->form_validation->set_rules('password', 'Password', 'required');

        if ($this->form_validation->run() == true) { //check to see if the user is logging in
            //check for "remember me"
            if ($this->input->post('remember') == 1) {
                $remember = true;
            }
            else {
                $remember = false;
            }
            
            if ($this->ion_auth->login($this->input->post('username'), $this->input->post('password'), $remember)) { //if the login is successful
                //redirect them back to the home page
                $this->session->set_flashdata('message', $this->ion_auth->messages());
                redirect($this->config->item('base_url'), 'refresh');
            }
            else { //if the login was un-successful
                //redirect them back to the login page
                $this->session->set_flashdata('message', $this->ion_auth->errors());
                redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
            }
        }
        else {  //the user is not logging in so display the login page
            //set the flash data error message if there is one
            $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
            
            $this->data['username']      = array('name'    => 'username',
                                              'id'      => 'username',
                                              'type'    => 'text',
                                              'value'   => $this->form_validation->set_value('email'),
                                             );
            $this->data['password']   = array('name'    => 'password',
                                              'id'      => 'password',
                                              'type'    => 'password',
                                             );
            
            $this->load->view('auth/login', $this->data);
            
        }
    }
#3

[eluser]Andy78[/eluser]
is this question too complicated or too dumb to be worthy of a response?




Theme © iAndrew 2016 - Forum software by © MyBB