Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Changing source of view files
  • Within your application, is there a way to change the source of view files? Basically, I just want to provide theme folders. They would contain identical resource files, but they would be symantically different. All of these would be available within views, and in their own respective directories. So more or less, when I call \View::factory('some_file'), I would want it to pull from the active theme's view/folder, rather than having to explicitly call the theme each time (\View::factory(\Config::get('theme') . '/some_file');
  • You can add an extra path to the current request using Request::active()->add_path() which will be used by Fuel's file locator to load files, and which have priority over the default paths; In case of views, the path you add must contain a folder called 'views', in which you store your views.
  • So I couldn't do something along the lines of
    /app/
    ---/views/
    -----/theme/
    -------template.php
    
    View::factory('template');
    

    ?
  • Could you use an absolute path? Something like Request::add_path(APPPATH.'views/theme'); ? I personally would add a themes directory in the APPPATH folder and do something like this...
    APPPATH
      - themes
        - mytheme
          - views
            - myview
    

    That's only if they share assets like I think you meant in your first post.
  • They utilize their own Assets, but that is handled easily enough through the asset class. The problem I'm seeing with this solution, is that I will be repeating the "views" folder over and over.. granted, the views are theme specific, but they're all still view files, and seem like they should be placed inside of the global views folder and separated out after. Kinda a let down that I can't do that :(
  • You could always extend the view class to accept different values. Right now I believe "views/" is a hardcoded prepend to the view being requested. It shouldn't be too hard. See the docs under "Extending core classes", it's dead simple.
  • I just didn't want to have to extend it, not that I couldn't :P
  • @Frank Bardon, Correct, views are searched for in 'views' folders, so that structure, like many others in a cascading filesystem, is mandatory.

Howdy, Stranger!

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

In this Discussion