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);
#2

[eluser]InsiteFX[/eluser]
Try this:
Code:
&lt;?php modules::run('modules/login/cp');?&gt;
// or this:
&lt;?php $this->modules::run('modules/login/cp');?&gt;

InsiteFX
#3

[eluser]eldrinofsoalim[/eluser]
Thanks for the quick reply InsiteFX!

I was able to get info from wiredesignz. He said that I shouldn't use the word "modules" but actual name of the module, which is "login". The format should be as follows:

Code:
Format: modules::run(‘module/controller/action’, $param1, $param2, .., $paramN);

I confused "module" for the word "modules", when it should mean the name of the module. In this case, it should be "login". So the "login" module will call the "login" controller, which calls the "cp" function.

Here's my setup

Code:
application/
  config/
  ...
  ...
  modules/
    login/
      controller/
        login.php
      model/
      view/

When I get back later, I'll try the following call to the HMVC:

Code:
&lt;?php modules::run('login/login/cp');?&gt;
// instead of
&lt;?php modules::run('modules/login/cp');?&gt;  
// or instead of
&lt;?php modules::run('login/cp');?&gt;

Do you think that will work? If not, I'll try your code next. But I doubt I can use...

Code:
&lt;?php $this->modules::run('modules/login/cp');?&gt;

since I'm calling it from the view, and not the controller.

What do you think? Thanks again for the help.
#4

[eluser]Unknown[/eluser]
hi frnds go through this post.

[url="www.manotechnologies.in"/]seo services[/url]
#5

[eluser]Unknown[/eluser]
if it is with Ion Auth hot to do? result me an error




Theme © iAndrew 2016 - Forum software by © MyBB