igaster / laravel-theme

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

View file path issue when loading from Namespace #131

Closed priyanganamal closed 3 years ago

priyanganamal commented 3 years ago

Hi,

I'm using the Laravel Modules package and all the view files are under a separate namespace. When loading the namespace view, I found the view path is getting wrong.

This is my theme paths 'themes' => [ 'pinsupreme' => [ 'extends' => '', // optional 'views-path' => 'pinsupreme', // defaults to: resources/views/theme-name 'asset-path' => 'pinsupreme', // defaults to: public/theme-name ], ]

And I have namespace call "Modules/Orders" so my folder path is /resources/views/<THEME_NAME>/Modules/Orders/Resources/Views

But this path is not loading. Instead, it loads the origin view path which is in /Modules/Orders/Resources/Views. (Not under theme folder)

So I dug the package coding, & I found it loads the following paths to search the correct view file.

array:6 [▼ 0 => "/private/var/www/trans_express/resources/views/pinsupreme/resources/views/pinsupreme/modules/orders" 1 => "/private/var/www/trans_express/resources/views/pinsupreme/resources/views/modules/orders" 2 => "/private/var/www/trans_express/resources/views/pinsupreme/Modules/Orders/Providers/../Resources/views" 3 => "/private/var/www/trans_express/resources/views/pinsupreme/modules/orders" 4 => "/private/var/www/trans_express/resources/views/modules/orders" 5 => "/private/var/www/trans_express/Modules/Orders/Providers/../Resources/views" ]

Now, the correct path is index #2. But it loads index #5

I found the issue come from the Providers/.. part. I cannot find how that part has come. Without that part, the path is correct.

Appreciate your help on this.

Thanks

priyanganamal commented 3 years ago

I fixed this myself. The issue was with the Module's Service Provider file. There is an another view path registration method, so the issue was fixed after updating the path on there.

igaster commented 3 years ago

Thanks for the feedback!