Welcome Guest, Not a member yet? Register   Sign In
HMVC: How to use module for dynamic widgets
#6

[eluser]Mark K[/eluser]
I am very sorry but I'm still confused. Let's have an example. Let's say I want to create a login widget (which is a module).

View:

Code:
<?php

echo form_open(base_url() . 'login/widget');

echo form_label('Email: ', 'txt_email');

$data = array(
    'name'          =>  'txt_email',
    'id'            =>  'txt_email',
    'type'          =>  'text',
    'placeholder'   =>  'Enter email address',
    'autocomplete'  =>  'off',
    'maxlength'     =>  '24'
);

echo form_input($data);

echo '<br>';

echo form_label('Password: ', 'txt_password');

$data = array(
    'name'          =>  'txt_password',
    'id'            =>  'txt_password',
    'type'          =>  'password',
    'placeholder'   =>  'Enter password',
    'autocomplete'  =>  'off',
    'maxlength'     =>  '16'
);

echo form_input($data);

echo '<br>';

echo form_submit('btn_login', 'Log In');
echo '&nbsp;';
echo form_button('btn_forgot', 'Forgot');

echo form_close();

Controller:

Code:
function widget() {
        
        $redirect_location = "name of url to redirect";
        
        if($this->input->post('btn_login')){
            
            $username = $this->input->post('txt_email');
            $password = $this->input->post('txt_password');
            
            if(Modules::run('user/validate_login', $username, $password)) {
                redirect(base_url() . $redirect_location);
            } else {
                redirect(base_url());
            }
        }

        $this->load->view('widget');
    }

If I want to have a login on two (2) different pages, I simply call the login module which is Module::run('login/widget'). For this example, how can I handle the redirects if this will be on two different pages? The solution that I think of is to pass variables. But is it a good practice?


Messages In This Thread
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 12:17 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 03:15 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 04:15 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 06:18 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 07:04 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 08:50 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 11:45 AM
HMVC: How to use module for dynamic widgets - by El Forum - 04-07-2014, 12:32 PM
HMVC: How to use module for dynamic widgets - by El Forum - 04-08-2014, 06:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB