[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>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
</head>
<body>
<?php echo modules::run('modules/login/cp');?>
<h2>Welcome Back, <?php echo $this->session->userdata('username'); ?>!</h2>
<p>This section represents the area that only logged in members can access.</p>
</body>
</html>
THE PROBLEM:
I can't seem to call cp() from the view using <?php echo modules::run('modules/login/cp');?>. It doesn't produce the user_widget. If I change the function called in the view (i.e. <?php echo modules::run('modules/login/RANDOMFUNCTION');?>

, I don't get an error.
If I remove the "modules" from the path (as in the original code in the article - <?php echo modules::run('login/cp');?>

, 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);