Support the ongoing development of Laravel.io →
Configuration Views
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

I don't want to rename my View::make argument, so that's a no-go.

Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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'
	...
)
Last updated 2 years ago.
0

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');

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Marwelln marwelln Joined 1 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.