Codeigniter 4 is MVC framework,ย MVC refers to Model, View and Controller. Here controller is used to backend, model is used to manage tables (database). And view used to user interface.
Codeigniter 4 is MVC framework,ย MVC refers to Model, View and Controller. Here controller is used to backend, model is used to manage tables (database). And view used to user interface.
Step 1:
Modify Home.php in controller.
First divide your page into three sections like header, content and footer.
'Home | CI tutorial' ]; echo view('layouts/header',$data); echo view('home'); echo view('layouts/footer'); } }
Controller file name should be start with uppercase letter and class name should be same as controller file.
Create user interface in views for
echo view('layouts/header',$data);
echo view('layouts/footer');
ย
Create layouts folder in views and create file header.php ย and footer.php inside that.
Create another page services and create subpages web services and email services under services.
'Services | CI tutorial' ]; echo view('layouts/header',$data); echo view('services'); echo view('layouts/footer'); } public function web_services(){ $data=[ 'title'=>'Web services | CI tutorial' ]; echo view('layouts/header',$data); echo view('web_services'); echo view('layouts/footer'); } public function email_services(){ $data=[ 'title'=>'Email services | CI tutorial' ]; echo view('layouts/header',$data); echo view('email_services'); echo view('layouts/footer'); } }
ย
Here we can pass data from controller to user interface (views) using an array.
Here I passed title for all pages from controller using array
For example,
Controller
$data=[ 'title'=>'Email services | CI tutorial' ];
Views
= $title; ?>
Now create view files services.php, web_services.php and email_services.php for services.
ย
Step 2:
Run your project
This is url for your home page
http://localhost/ci_tutorial/
And
ci_tutorial/index.php/services ci_tutorial/index.php/services/web_services ci_tutorial/index.php/services/email_services
for services page
If you want to run your project without index.php create .htacces file in your root folder like this
and paste this code and save.
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]
ย
Now you can run project directly without index.php,
ci_tutorial /services ci_tutorial/services/web_services ci_tutorial/services/email_services
Step 3:
Add bootstrap layout and meta tags for your user interface.
paste this inside of head ta๏ปฟg and
ย
Paste this before end of the body tag
Now add bootstrap navigation header after body tag
Here base_url(); is your site URL.
Open App.php file inside config folder and define your base url,
public $baseURL = 'http://localhost/ci_tutorial/';
Add base_url(); to tag
Home
Cricket is more than just a sport in Indiaโitโs a passion! From big stadiums like Wankhede and Eden Gardens to smaller, cozier grounds, each has its own charm. But have you ever wondered which is the smallest cricket stadium in India? In this guide, weโll explore the top 12 "smallest cricket stadiums in the India by boundary", their unique features, and why theyโre special. Whether you're a cricket fan or just curious, this fun and easy-to-read article will give you all the details!
In cricket, fielding is a genuine skill. Over the years, I have seen hundreds of matches across formatsโTest, ODI, and T20. From stunning dives to lightning-fast reactions, I've always been astonished by players who rescue valuable runs and make unbelievable catches. That is why I chose to discuss the "Best fielder in the world of all time". Using data, personal experiences, and a passion for the game, this blog will guide you over the field of fielding.
Hey there, cricket fans! Sharing what I know about the Asia Cup 2025 makes me quite happy.
Salman Khan has been advised by the Bishnoi community of Rajasthan to apologize in the blackbuck poaching case - but will the matter end if Salman Khan does so? And will Salman Khan want to take this path?