Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Controller_Template + Module
  • Hi all, Trying to move my Controller_Common (Which all my controllers extend from) to a module. So far it has worked quite well, except that I can't seem to reference my base template using
    namespace Common;
    
    class Controller_Common extends \Controller_Template
    {
     public $template = 'base';
    
    
    It doesn't want to use the template in the module and keeps trying to load the template from the app view directory.
    I have tried appending directories to the template name
    public $template = 'common/base';
    
    or
    public $template = 'common_base';
    
    to no avail. I am extending from this by using the following method.
    class Controller_Welcome extends \Common\Controller_Common
    {
    
    which works perfectly if the base view is in the app directory. Anybody have any suggestions on this one? Thanks
  • The finder works with a "request context", it knows what was requested, and searches based on that, and not on which piece of code you're in. So if you call this module controller via the URL (/common/common/index) or via a Request::forge('common/common/index'), the finder knows you're in the common module, and will start searching there. If you call this Controller from another controller in app, the context will be your application, and no module views will be loaded. In this case you're not calling it, you use it as a base class. If Controller_Welcome is in app, that's your request context. How would the finder know to look somewhere else?

Howdy, Stranger!

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

In this Discussion