Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Modules
  • What's up! I'm trying to convert my old codeigniter app to FuelPHP and I want to make my app completely modular. Now I've read through the documentation, but I'm kinda stuck at this points. I have this folder structure: ../modules/navigation
    ../modules/navigation/controller/navigate.php
    ../modules/navigation/model/navigation.php
    ../modules/navigation/views/menu.php This is my controller code:
    <?php
    /**
    * Created by Nick Verheijen
    * Date: 12/19/11
    * Time: 2:05 PM
    */
    namespace Navigation; class Controller_Navigate extends \Controller { public function action_show()
    {
    echo "test";
    } }

    I want to load a view in that method, but I dont know how? Since the module has it's own "views" folder. So that's question number one. And my second question is how do i load my module's controller's function into selected template region. This is what i have so far:
    $this->template->menu = Request::forge('navigation/navigate/show');

    But that does not give me any output at all when echo'ed. Thanks in advance,
    Nick
  • here is the simple practice i have done to learn fuelphp .it may help you to learn
    https://github.com/samitrimal/mod-cms
  • You load module view the same way as views in an app controller, using \View::forge(). Your controller method should return a response object, which can contain anything, but for your case it could contain a view. Something like:
    class Controller_Frontend extends \Controller
    &#123;
        // fetch a partial
        $partial = \Request::forge('navigation/navigate/show', false)->body();
    }
    

    And the module controller:
    namespace Navigation;
    
    class Controller_Navigate extends \Controller
    &#123;
        public function action_show()
        &#123;
            // return the modules/navigation/views/navview.php view file
            return \Response::forge(\View::forge('navview'));
        }
    }
    

Howdy, Stranger!

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

In this Discussion