Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Using Template Controller within module
  • Hi Guys! I'm trying to use the Template Controller within a modules, here's my module structure and code. (from the docs) app
    --views
    ---template.php


    modules
    --registration
    ----classes
    controller
    model
    ----views
    index.php
    <?php
    namespace Registration; 
    Class Controller_Registration extends \Controller_Template 
    { 
        public function action_index() 
        {
        $this->template->title = 'Example Page';
        $this->template->content = View::factory('registration/index', $data);
    }
    }
    

    I keep getting ErrorException [ Error ]: Class 'Registration\View' not found
    I also tried $this->template->content = View::factory('index', $data); but getting the same error. What am I doing wrong?
  • Thanks :)
  • You forgot the backslash before "View", now it tries to get the View class from the Registration namespace. Exactly as the Error message says. You need to add the slash to the requesting the view:
    $this->template->content = \View::factory('registration/index', $data);
    

Howdy, Stranger!

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

In this Discussion