Welcome Guest, Not a member yet? Register   Sign In
HMVC Problem: Calling module from View
#1

[eluser]eldrinofsoalim[/eluser]
Hi! I'm starting to learn HMVC and I really think that it can do wonders. It might be what I need to actually create an admin-member-non-member website.

I'm just running encountering a problem. It seems there's a problem with calling HMVC from the view. I'm currently following the Net Tuts HMVC: an introduction and application. Let me explain:

Here are the functions:

THE CONTROLLER FUNCTION UNDER "LOGIN" MODULE:

Code:
function cp()  
{  
    if( $this->session->userdata('username') )  
    {  
        // load the model for this controller  
        $this->load->model('membership_model');  
        // Get User Details from Database  
        $user = $this->membership_model->get_member_details();  
        if( !$user )  
        {  
            // No user found  
            return false;  
        }  
        else  
        {  
            // display our widget  
            $this->load->view('user_widget', $user);  
        }  
    }  
    else  
    {  
        // There is no session so we return nothing  
        return false;  
    }  
}

and

THE VIEW UNDER THE "SITE" MODULE:

Code:
<!DOCTYPE html>  
&lt;html lang="en"&gt;  
&lt;head&gt;  
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;  
    &lt;title&gt;untitled&lt;/title&gt;  
&lt;/head&gt;  
&lt;body&gt;  
    &lt;?php echo modules::run('modules/login/cp');?&gt;  
    <h2>Welcome Back, &lt;?php echo $this->session->userdata('username'); ?&gt;!</h2>  
     <p>This section represents the area that only logged in members can access.</p>  
&lt;/body&gt;  
&lt;/html&gt;

THE PROBLEM:

I can't seem to call cp() from the view using &lt;?php echo modules::run('modules/login/cp');?&gt;. It doesn't produce the user_widget. If I change the function called in the view (i.e. &lt;?php echo modules::run('modules/login/RANDOMFUNCTION');?&gtWink, I don't get an error.

If I remove the "modules" from the path (as in the original code in the article - &lt;?php echo modules::run('login/cp');?&gtWink, I get an error:

Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Login::$session

Filename: controllers/login.php

Line Number: 91

Is there something wrong with the code? I followed the guide to the letter except when I had to edit the module::run call from module::run('login/cp') to module::run('modules/cp') to follow the format specified:

Quote:Format: modules::run('module/controller/action', $param1, $param2, .., $paramN);


Messages In This Thread
HMVC Problem: Calling module from View - by El Forum - 04-25-2011, 06:38 PM
HMVC Problem: Calling module from View - by El Forum - 04-25-2011, 08:38 PM
HMVC Problem: Calling module from View - by El Forum - 04-25-2011, 10:18 PM
HMVC Problem: Calling module from View - by El Forum - 04-26-2011, 12:13 AM
HMVC Problem: Calling module from View - by El Forum - 01-20-2012, 12:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB