Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
I think Theme has wrong order.
  • I have module... example: shop.

    In my shop controller call theme view -> (front/templates/index/index_v)

    FuelPHP look into [my active theme] and use it instead of look into [my active theme]/modules/[module name]/[view file path] and then look into [modules folder]/views/[view file path]

    For more clear...
    This is my theme folder.
    themes
    ...........mytheme
    ..........................front
    ................................templates
    ..............................................index
    .....................................................index_v.php < this file location is (themes/mytheme/front/templates/index/index_v.php)

    If i put view file into (themes/mytheme/modules/shop/front/templates/index/index_v.php) the theme will be load correctly.

    But if i don't put view file in there.
    The theme class should look back into the module caller views folder. In this case it should look into (modules/shop/views/front/templates/index/index_v.php).
    The theme class don't look at module caller views folder. but it look at (themes/mytheme/front/templates/index/index_v.php) which i think it is wrong order.

    \Theme::instance()->active('mytheme')->view('front/templates/index/index_v', $output, false);
    This should be correct order.
    1. [theme folder]/mytheme/modules/shop/front/templates/index/index_v.php where shop/ is same as module folder name.
    2. [modules folder]/shop/views/front/templates/index/index_v.php
    3. [theme folder]/mytheme/front/templates/index/index_v.php



  • The theme class always loads from the themes folder, it never loads from the views folder.

    Even if you configure it to use modules, it will load from a themes folder inside the module. Theme views are completely separated from normal views.
  • Yes, but at least if theme class look in theme folder/modules/module name and then modules/module name/views is more relevant than always look in theme folder then look in modules/module name/views.

    from my theme order example
    1. [theme folder]/mytheme/modules/shop/front/templates/index/index_v.php where shop/ is same as module folder name.
    2. [modules folder]/shop/views/front/templates/index/index_v.php
    3. [theme folder]/mytheme/front/templates/index/index_v.php

    if theme class look in choice 1. then 3. The choice 3. is theme file of index controller in fuel/app/classes/controller/index.php which is not relevant with the module caller (modules/shop/classes/controller/index.php).

    This is what i was extended in theme class > find_file.

    if ($module_path and ! empty($theme['name']) and is_file($path = $module_path.$theme['name'].DS.$file.$ext)) {
                        // if use_modules is true then this $path will be /www/root/modules/<module name>/themes/<theme name>/<$view>.php
                        return $path;
                    } elseif (is_file($path = $theme['path'].$path_prefix.$file.$ext)) {
                        // if use_modules is true then $path will be /www/root/<theme path>/<theme name>/<module name>/<$view>.php
                        // if use_modules is 'modules' then $path will be /www/root/<theme path>/<theme name>/modules/<module name>/<$view>.php
                        return $path;
                    } elseif (is_file($path = \Module::exists($module) . 'views' . DS . $file . $ext)) {
                        /**
                         * this condition was added by Vee W.
                         * look directly in modules/module_name/views. this $path will be /www/root/<modules path>/<module name>/views/<$view>.php
                         *
                         * @author Vee W.
                         */
                        return $path;
                    } elseif (is_file($path = $theme['path'].$file.$ext)) {
                        // this will not look into module name anymore. $path will be /www/root/<theme path>/<theme name>/<$view>.php
                        return $path;
                    }

    This is also better when you copy module to use with other projects.

    In some project you may have "load theme file" like this ('front/templates/index/index_v) and you have to copy module theme files from old project because the other project already have 'front/templates/index/index_v' in themes folder which is really not relevant to your module.

    If the theme class have theme file order like i says. You can just copy module to use with other projects and see the prototype render the theme correctly without copy those theme files from themes folder(and easy too).

    Please add code to re-order theme file locator if you agree with me about more relavant file location. :)
  • It will never look at file number 2, and it was designed that way, standard views !== theme views.

    Why would you want to mix them? You as a developer are in full control, so you can make sure they are in the correct location?

    If you insist on using a plain view, you can pass a View object to set_partial, and solve it that way.

Howdy, Stranger!

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

In this Discussion