Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Modules and Views
  • Hello,

    I am working on an user module for one of my projects. The module should basically handle session management (login/logout) and edit the user profile.

    This is my structure:

    # fuel
    ## modules
    ### users
    #### classes
    ##### controller
    ###### login.php
    ##### views
    ###### login.php
    ## app
    ### views
    #### login.php

    Inside the login-controller I call 
    return \Response::forge( \View::forge('login', $data ) );

    Now, my question is: Is there a way to tell fuel to use the view from the app (if there is one) and not from the module? But I want to use the view from the module as fallback (if there is no view-template in the app)?
  • Hi,

    EDIT: Sorry bad response

  • It will automatically do that if the module does not contain a view called 'login'.

    If the module does contain one, there is no way you can force it to load the global one. Not a good architecture anyway, you'll drop all loose coupling you want for your modules...
  • Ok, but what would be a better architecture to solve such problems?

    I want to create app-independent modules (like user handling) and inside the app, I want to customize the modules (for example change the view/template). 
  • Maybe try to extend the function locate() in Fuel_Finder. I don't see other solution
  • HarroHarro
    Accepted Answer
    I suggest you look at the Theme class which is designed to decouple the views from the code (both module and app).

    It allows you to store the default theme template views in the module (or app), and override them in the theme folder. It also allows you to use multiple themes at once.
  • Ok, themes are looking good.

Howdy, Stranger!

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

In this Discussion