0
votes

I've just discovered HMVC Modular Extension for CodeIgniter https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home and it seems perfect for my needs but I have some question.

Let's say I have two controllers:

  • Site which is the main controller and is used to show site's pages and may call methods of Users controller for example to show a form
  • User controller is used to authenticate users, to show login/sign up forms...

Now I have these questions:

  1. If the user access the User controller directly (mysite.com/user/method) I want to show a full page while if i load a method of User from within the Site controller I want to show only a form (for example), is this possible?
  2. What happens to view of a module loaded from another module: is the view shown automatically or i need to show it manually and how does the view behave?
1

1 Answers

2
votes

If you method is being called via Modules::run()

There is a third optional parameter lets you change the behavior of the function so that it returns data as a string rather than sending it to your browser.

Eg:

//put underscore in front to prevent uri access to this method.
public function _module1()
{
     $this->load->view('partial_view', array('some data'=>'some data'), TRUE)
}

call it inside your SITE view easily

Modules::run('User/_module1')
// should show whatever is in partial_view ie: a form

//an alternative is to pass in any params if the method requires them
Modules::run('User/_module1', $param)