Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
template file not found, bug?
  • I used \Theme::forge method. i have two themes set by default
    one for backend and frontend.  what is the best way to impliment it.

    i have used forge method, in public view and backend view.

    each one in same directory app/themes... as app/themes/frontend & app/themes/backend
    theme name is same "default".template file is "template.php"
    My frontend theme controller is in bin.
    http://bin.fuelphp.com/snippet/view/LO

    I getting Error as template file not found, \Debug::dump($this->theme) is shown in bin.
    http://bin.fuelphp.com/snippet/view/LN


  • What version of Fuel are you on? I see in your dump some Windows related issues that are solved in the current version as far as I know.

    It is looking for "D:\xampp\htdocs\dir.dev\fuel\app\themes\frontend\default\.\template.php", does that exist?

    If you want "frontend" and "backend" to be a theme, then you're using it wrong, and should instantiate the theme like so:

            // load the theme template
            $this->theme = \Theme::forge(array(
                'paths' => array(
                    APPPATH.'themes',
                ),
                'view_ext' => '.php',
                'active' => 'frontend',
            ));

    And then your template would be in D:\xampp\htdocs\dir.dev\fuel\app\themes\frontend\template.php.

    This seems to be a better idea, so you have use a single theme instance, and use $this->theme->active('frontend') and $this->theme->active('backend') to switch between the two.
  • Then How can i give opportunity to users to change their theme if they want to.

    i want front end and backend themes in separate folders. Any ways

    i am using 1.7.3 version
  • If you do it that way, they are in different folders?

    Or do you want to have a selection of frontend themes, and a selection of backend themes? In that case it will probably make sense to split them like you did, and your config should work fine.

    You haven't answered my question if the file path generated is the path where you have stored your themes? If that is not the case, how have you organised it?
  • Dear,

    i am storing my themes in App/themes/frontend or backend/default/template.php
    both have same structure, but frontend & backend folder difference. According to my knowledge, it should work, But it not working.

    working perfect when created by instance, default config. but error when created with forge.

    i checked both object with \Debug::dump() , but seem same, but forged one not working, instance working perfect, but in instance, i cant isolate folders, How i do so?
    Any way?
    Kindly Help

  • I have no clue what you're on about.

    Instance() does exactly the same as forge(), only difference it that is stores the instance by name so you can retrieve it later, while forge() always forges a new object.

    I understand where you store your themes, and if you want to do it that way, the code in http://bin.fuelphp.com/snippet/view/LO looks perfectly fine.

    With that config, it tries to load the template from "D:\xampp\htdocs\dir.dev\fuel\app\themes\frontend\default\.\template.php", and I asked you if that file exists or not. Which you still haven't answered.

    I have no clue where that "\.\" in that filename comes from, did you change something in the app/config/theme.php file as well?

    So does this file exist or not, what is the exact error you are getting, and which file and which line throws the error?
  • \.\ is not a issue, i executed path with \.\ and without \.\ . both works fine.
    the file truely exist as you asked, the file works fine if i load the file using \Theme::instance();. i found using forge and instance both have \debug::dump() same.except a instance variable is set in instance object.

    exactly i am confused. tried for 3 days now, the template object is set when dump, but still showing error
    Fuel\Core\ThemeException [ Error ]:
    No valid template could be found. Use set_template() to define a page template.

    D:/xampp/htdocs/dir.dev/fuel/core/classes/theme.php @ line 354



    this one shows error
    controller: http://bin.fuelphp.com/snippet/view/LR
    dump: http://bin.fuelphp.com/snippet/view/LT

    this one not.
    controller: http://bin.fuelphp.com/snippet/view/LS
    dump: http://bin.fuelphp.com/snippet/view/LU

    i am using v1.7.3

    if possible, kindly give me a working theme forge controller and a template file as bin, so that i can compare with it. must be forge type, as i need to host multiple theme in future.

    screenshot attched for file structure.
    the opened php file is theme config file. http://imgur.com/sngs49t

    and very wonderful matter i found is that, using both forge and instance, $this->theme->find('default'); return path same.
    thanks in advance
  • HarroHarro
    Accepted Answer
    That is quite logical.

    As I said, when you use forge(), you are just creating an object. Like you would when you use "new". But in the after() method when you render the page, you use Theme::instance().

    This uses a COMPLETELY different instance of the Theme class. Do

    var_dump($this->theme, Theme::instance())

    and you will see that you have two different objects (check the object id).

    So either use Theme::instance() everywhere, or use $this->theme everywhere, but don't mix the two.

    For consistency I suggest you use forge() everywhere, and replace the line in after() with

    $response = \Response::forge($this->theme->render());

  • Works Perfect..

Howdy, Stranger!

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

In this Discussion