igaster / laravel-theme

Theme support for Laravel
MIT License
520 stars 113 forks source link

Using configSet on themes_path does not appear to change where views are searched for #41

Closed andybeak closed 8 years ago

andybeak commented 8 years ago

I wanted to swap to use a different base directory when running tests so that I could keep views that I use for testing separate from production templates.

        $testPath = realpath(base_path('resources/views/test_theme'));

        Theme::configSet('themes_path', $testPath);

        var_dump(Theme::config('themes_path'));

        var_dump($testPath);

The output shows that the config value is changing but it's looking in the default location set up in settings.

The code looks for files in ...../resources/views/themes/300

igaster commented 8 years ago

Hi @andybeak,

1) themes_path should be treated like any laravel configuration value. You should set it with

config(['themes.themes_path' => 'your_value_here']);

2) Take in account that all the paths are initialized in themeServiceProvider.php at bootstraping. So changing the settings later will have no effect. I believe setting the configuration in a custom service provider BEFORE themeServiceProvider will do the trick!

Please let me know if it works for you!

cheers!