igaster / laravel-theme

Theme support for Laravel
MIT License
516 stars 110 forks source link

Theme inherits defaults theme's path #53

Closed dsbilling closed 7 years ago

dsbilling commented 7 years ago

2017-05-16 18_38_19

For some reason, after upgrading to 5.4 and updating this package to 1.14, this happens. It adds the default theme to the start if another theme is selected. Why?

<?php

return [

    'enabled' => true,

    'themes_path' => null,

    'asset_not_found' => 'LOG_ERROR',

    'active' => 'frontend',

    'themes' => [

        'bootstrapextended',

        'frontend',

        'neon-admin',

        'neon-user',

    ],

];
danstreeter commented 7 years ago

I'm getting this too - haven't delved deep enough into the package or Laravels internals to figure out why yet but have got around it by defining my theme path a little more 'absoute' in the config file:

screen shot 2017-05-28 at 18 00 46
igaster commented 7 years ago

Hello I've tried to reproduce the issue but in my setup everything seems to be fine... I used @DanielRTRD configuration file and got a normal error:

InvalidArgumentException in FileViewFinder.php line 137:
View [tests] not found.
in FileViewFinder.php line 137
at FileViewFinder->findInPaths('tests', array('/home/vagrant/Code/smarthotels/resources/views/neon-admin', '/home/vagrant/Code/smarthotels/resources/views')) in FileViewFinder.php line 79

Can you share some additional information? Where are you setting your theme? (Controller? Service Provider? Middleware?)

You can update to latest version v1.15 first so that we will have the same installation...

dsbilling commented 7 years ago

I used a provider to set the theme.

Updating to 1.15 solves the problem!

dsbilling commented 7 years ago

This problem popped up again while I was merging branch.

laravel/framwork: v5.4.24 igaster/laravel-theme: v1.15

Provider file:

<?php namespace LANMS\Providers;

use Illuminate\Support\ServiceProvider;

class ThemeSelectServiceProvider extends ServiceProvider {

    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        if (\Request::segment(1)=='admin') {
            \Theme::set('neon-admin');
        }

        if (\Request::segment(1)=='user') {
            \Theme::set('neon-user');
        }

        if (\Request::segment(1)=='account' && \Request::segment(2)=='register' || \Request::segment(2)=='login' || \Request::segment(2)=='forgot' || \Request::segment(2)=='recover' || \Request::segment(2)=='activate' || \Request::segment(2)=='resetpassword') {
            \Theme::set('neon-user');
        }
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

}

Config:

<?php

return [

    'enabled' => true,

    'themes_path' => null, 

    'asset_not_found' => 'LOG_ERROR',

    'active' => 'frontend',

    'themes' => [

        'bootstrapextended',

        'frontend',

        'neon-admin',

        'neon-user',

    ],

];
igaster commented 7 years ago

Hello, v2.x has been published. If you upgrade you may check again if the problem persists...

Requires L5.4