Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using module but render in my template app
  • I want to use modules but I can't render view them in my template app.

    How can I solve it? Using themes?






  • You have to be more specific, what exactly are you trying to do?

    Modules are designed to split your app in self contained functional parts. A request for such are part is then routed to a module controller, and that can access files in a module.

    I have a feeling you're trying to call cross module, which is a bad idea, as it destroys the loose coupling that need to exist between modules (and the app). If you want to load a view from a module from an app controller or a controller in another module, use an HMVC call to that module and have that return the view.
  • Perhaps with an example be easier.

    Normally app.

    Controller_Hello:
        public function action_index()
        {
            $this->template->title = "Hello my friend!";
            $data['hello'] = 'Hello world!';
            $this->template->content = View::forge('hello/index', $data);
        }

    It will renders the variable "content" in my template.

    Therefore, I want to utilize modules but to render in "content" for to use existing infrastructure (menu, auth and etc).
  • I understand this bit of code, but don't understand the relation with a module. You want to replace the View::forge() call with a view from a module?

    That is very bad practice, the only clean why to do that is to use an HMVC request to a module controller, and have that return the view.
  • I understand Harro, but the app "depot" utilize this concept (HMVC)?

    I wanted to use the same concept but without the Themes.

  • I don't think Depot uses cross-module calls at all.

    It uses a base controller that sets up the page template, and adds the 'content' second from the module controller itself.

    It utilizes the fact that there's a fallback to app for View::forge(), so you can global views that are loaded from app/views, and module views that are loaded from app/modules/yourmodule/views.

    That works as long as you use unique names for your views. I tend to use app/views/templates for page templates, and app/views/global for global views, like a header, footer, etc.

    And for the modules itself we use a dynamic system, where the before() of the base controller gets a list of loaded modules, and does an HMVC call to a controller in every module called "Controller_Module". This has methods like "action_menu", which will return menu options to add, it has others as well.

    So depending on the modules loaded, and the permissions the user has, the menu will be generated dynamically.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion