Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Theme WSOD
  • Ok,

    I have searched and searched and can't get themes to work.  I always end up with a WSOD.

    classes\controller\templating.php:

    public function action_index()
    {
    //Login Check
    $userCheck = \Auth::check();
    if(!$userCheck){
    \Response::redirect('login');
    }
    //User Logged In
    \Theme::instance()->set_template('layouts/vatusa');
    // MORE CODE
    }


    The theme is in "fuel\app\themes\vatusa
    Assets are in public\themes\vatusa\

    fuel\app\config\theme.php

    return array(
    'active' => 'vatusa',
    'fallback' => 'vatusa',
    'paths' => array(APPPATH.'themes',),
    'assets_folder' => 'themes',
    'view_ext' => '.php',
    'require_info_file' => false,
    'info_file_name' => 'theme.info',
    );


    I have gone over the documentation and even looked at the stuff here: https://github.com/fuel/depot/

    something is obviously wrong or missing here.........


  • HarroHarro
    Accepted Answer
    Where are you rendering your template?

    Easiest is to take a copy of Controller_Template (which is in fuel/core/controller/template.php), swap the View code in there for Theme code, and use that as a base controller for your controllers.

    In the after() method, if the method called didn't return a response, you create a new response with the Theme instance as payload.
  • I'll see if I can add a Theme base controller to the framework, so you don't have to invent the wheel...
  • Thank you Harro,

    I don't mind inventing the wheel.  Just took a 15th look at the depot code to get it sorted out.
  • Something like http://bin.fuelphp.com/snippet/view/kz

    Just have your controllers extend it, set the $template property in your controllers to the desired page template, and use \Theme::instance()->set_partial() in your methods to define template partials.

    Providing you've got the theme.php config correct, this should work...
  • Thanks for all the help Harro,  I am learning more and more every moment working with Fuel.

    I have the theme system working, now I just need to pass variables to my partials.  I am calling $theme->set_partial('header','layouts/header')->set('title', $title);  and in the partial i am calling <?php echo $title; ?>

    But I am getting an undefined variable exception. 
  • That is exactly how it should, so the problem must be elsewhere.

    if you do a

    var_dump($__data)

    in the partial, you should see everything that is passed to the view.

Howdy, Stranger!

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

In this Discussion