You can instruct Laravel to search additional paths for views like this
View::addLocation('/additional/path/to/search/in');
Also, there's possibility to add namespaced views:
/* register */
View::addNamespace('Foo', '/path/to/foo/views');
/* and use it */
return View::make('Foo::view.name');
This doesn't answer your question precisely but this way you'll be able to use views from non-standard locations.
I don't want to rename my View::make
argument, so that's a no-go.
But in case of View::addLocation()
you will not need to touch your View::make()
arguments. Laravel will scan the additional locations and find the right view.
I fixed this by extending the ViewServiceProvider
.
<?php
namespace Redward\Illuminate;
class ViewServiceProvider extends \Illuminate\View\ViewServiceProvider {
/**
* Register the view finder implementation.
*
* @return void
*/
public function registerViewFinder() {
$this->app->bindShared('view.finder', function($app) {
$path = condition ? 'view.pathsAdmin' : 'view.paths';
$paths = $app['config'][$path];
return new FileViewFinder($app['files'], $paths);
});
}
}
Then changed the providers
array in config/app.php
from
providers => array(
...
'Illuminate\View\ViewServiceProvider'
...
)
to
providers => array(
...
'Redward\Illuminate\ViewServiceProvider'
...
)
marekmurawski said:
You can instruct Laravel to search additional paths for views like this
View::addLocation('/additional/path/to/search/in');
Also, there's possibility to add namespaced views:
/* register */ View::addNamespace('Foo', '/path/to/foo/views'); /* and use it */ return View::make('Foo::view.name');
This doesn't answer your question precisely but this way you'll be able to use views from non-standard locations.
great answer :
/* register */ View::addNamespace('Foo', '/path/to/foo/views');
/* and use it */ return View::make('Foo::view.name');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community