How to create a subfolder inside controller and view folders in codeigniter? - 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!

Related

Handling multiple views controllers in CodeIgniter 4

I am new to CodeIgniter 4.
I have one controller named Pages and helps to display website pages normally. Then I have another controller named Admin which is suppose to load the admin view with its own header and footer files.
While Pages controller works fine, the Admin controller keeps saying 404-file not found admin.
I think I have a problem with my current Route settings below. Please help.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');
try ajusting your code like this.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->resource('pages');
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');

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.

Codeigniter - dots in a controller folder name

I'm using the latest version of Codeigniter and I try to achieve specific controller folders structure.
I'm would like to create a controller folder for each of my webapp version:
/controllers/1.0.0/login (where login is the name of the controller)
/controllers/2.0.0/login (where login is the name of the controller)
the problem: it seems Codeigniter working great with controller folders but not working with controller folders that contain dot :(
Like this working good (without dots):
/controllers/100/login (where login is the name of the controller)
/controllers/200/login (where login is the name of the controller)
Is there a way to make Codeigniter work with dots on controller folders?
Thanks
Shai
I also getting the same issue.
You can use like this in your route
config/route.php
$route['Controller/1.0.0/login'] = 'Controller/100/login';
$route['Controller/2.0.0/login'] = 'Controller/200/login';
This is working fine for me

How to connect a view file inside the sub folder of view folder in codeigniter

I am having subfolder named 'auth' inside the view folder, and i am having a controller named 'job' i am having some files inside "auth" folder where i have to call in some form actions and also for some validations like the users are already login, email verifications etc etc....
I am new to codeigniter so please help.me how i can connect the files which is inside a "auth" folder to forms and various validations
I also tried by $this->load->view('auth/login') but not working, is there anything i have to do
Please reply with explanations as i am doing a project it will help.me in future projects

Load views based on REQUEST_URI

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.

Resources