在我的Laravel4应用程序的根目录中,我有一个文件夹100.在100文件夹里,我有102103. 如何通过特定路由从此104文件夹访问视图.

Route::get('{slug}', function($slug) {
    // make view from themes/default here
});

My directory structure:

-app

--themes

---default

---azure

I need to load views from localhost/laravel/app/themes/default folder. Please explain this.

推荐答案

Here I am not accessing my project from public folder. Instead of this I am accessing from project root itself.

I have seen a forum discussion about Using alternative path for views here. But I am little confused about this.The discussed solution was,

You'd add a location like,

View::addLocation('/path/to/your/views');

然后为主题添加100

View::addNamespace('theme', '/path/to/themes/views');

Then render it,

return View::make('theme::view.name');

What will be the value for /path/to/ ?

Can I use the same project in different operating system without changing the path?

是的,我们可以使用以下方法,

Put the following in app/start/global.php

    View::addLocation(app('path').'/themes/default');
    View::addNamespace('theme', app('path').'/themes/default');

然后以默认方式调用view,

    return View::make('page');

这将呈现project_directory/app/themes/defualt文件夹中的page.phppage.blade.php个文件.

Laravel相关问答推荐

Laravel-如何按第三表关系对数据进行分类

如何保存/重定向 Laravel Artisan 命令的输出?

Laravel 集合排序不生效

Laravel - 将变量从中间件传递到控制器/路由

Laravel 错误ReflectionException-类 App\Http\Kernel 不存在

Laravel PHP 框架的新手. /以外的路由不起作用

允许的内存大小 134217728 字节用尽(试图分配 20480 字节) Laravel

如何在 laravel 中使用 str_replace

Laravel 框架类在 PHPUnit 数据提供程序中不可用

致命错误:找不到类App\Http\Controllers\Redirect

在表单中添加一对多 - Backpack laravel

从 sqlite DB 登录 Laravel,得到PDOException 找不到驱动程序

在 Laravel 中下载后如何重定向?

错误:您的要求无法解析为一组可安装的软件包.

使用 laravel eloquent 关系检索除 NULL 之外的所有记录

如果用户未登录 Laravel,则重定向到登录

如何在 Eloquent Orm 中实现自引用(parent_id)模型

Laravel - artisan不工作

如何在脚本文件中使用 Laravel Blade?

错误:找不到模块 'webpack/lib/rules/DescriptionDataMatcherRulePlugin' 需要堆栈: