Load views based on REQUEST_URI - laravel-4

I want to create a setup where I can load views from a view folder based on the first part of the REQUEST_URI.
domain/folder1/ to load views from views/folder1 folder
domain/folder2/ to load views from views/folder2 folder
How would i set it up for it to work automatically? Can i modify the view path at a certain part of the lifecycle?

Thats not how you should do it. The router shouldnt call the view directly (nor the user in your case). Create a controller and asign the views with its data there.

Related

Dynamic Folder per customer

I've a problem I don't know the solution.
I want when a user click a button (which i have design) it will call the controller method. In this method
I want to create a folder if it doesn't exist already in my view directory.
Copy a file into that new created directory which is a blade file.
Return that blade file with some data.
I've tried some methods but it doesn't work.
I'm unable to create the file inside the view and then copy the blade file into it.

How to create a subfolder inside controller and view folders in codeigniter?

I wanted to create a folder named 'schoollevel' inside controller and view folder to create a separate module containing login function and profile views to provide another login functionality for some users. The 'schoollevel' contains all the files for login and profile view. Can anyone suggest how to do this ? I want the control to go to the separate folder.
Its Easy to create folder in controller and view in codeigniter.
Folder name : school
1.create a login controller
application->controller->school->Login.php
create a login view
application->view->school->login.php
Now, How to call view file
Inside login controller in the index() function add
this to call login.php view
$this->load->view('school/login');
I hope this help you!

Laravel - master view loads a view in index view but cannot load it in create view

I have a layouts folder under views folder where the master.blade.php is placed and I have includes folder under views folder where nav.blade.php is placed.
I have a users folder under views where index.blade.php and create.blade.php are placed.
Now i have extended the master view in both index and create views but the problem is that index page shows the navigation bar which is in includes folder and create page does not show it.
Master Page:
Index Page:
Create Page:
I googled this but could not find any solution.
Probably there are some issues in loading css and js files into the page.
To be sure to load them correctly don't write the path by hand but use the method:
URL:asset()
https://laravel.com/docs/5.4/helpers#method-asset

Move Codeigniter's Model, View and controller folders outside Application

I would like to change/move the Model, View and Controllers folder from application folder and want them to be keep support in a new folder called app. Can someone please give me a solution which would work on CI-3*
application/
library
config
helpers
core
......
app/
model
views
controllers
index.php look for $application_folder and modify this.
You can move views separately using the $view_folder variable.
However, without changing the way the core of CI works you'd have to keep models/controllers inside of application.

Laravel 4 - Accessing Folders

I am new to Laravel 4, and I come from a Zend Framework background. I'd like to create a folder app/forms and keep all my forms there. How can I refer to the form in the controller and within the view.blade files?
By default, the root of the view files folder is app/views so if you create a folder in views like app/views/forms then you may refer the form by it's name from a controller like:
$form = View::make('forms.formfile');
Here, formfile is the name of the file that contains the form and it could be formfile.blade.php and to refer/include the form file from a view you may use #include:
// In a blade view file
#include('forms.form1')
Assume that, form1 is a blade view inside the forms folder and saved as form1.blade.php, you may also use sub-folders inside the forms folder, for example in views/forms/user folder you may keep a view named index.blade.php and use it like:
// From a controller
$userForm = View::make('forms/user/index');
From a view file: (folders are separated by .)
#include('forms.user.index') // file: app/views/forms/user/index.blade.php
You can also nest views in the controller, check the manual for more.
From the standpoint of Laravel, HTML forms (and all presentation related things ) belongs to app/views/ folder. Exceptions are package specific views. For example some commands has their own stubs and views and they are usually stored inside package.
Laravel is very flexibile, and you can move things around and create new folders and namespaces. You just have to tell composer that you are changing Laravel default structure, and dumpautoload. That is if you only want to create new folder with internal reference. If you want something with more scope and visibility you'll have to bind that to container, so that will be visible inside whole application.
You are coming from the Zend world, so I can understand that you want to move some of Zend "flavour" to Laravel. Although is it possible, I would really recommend you to take some time and learn how Laravel works. There are some great ideas and design inside. Of course, Zend has its own quality, but hey - this is Laravel :)

Resources