Saturday, November 14
Trending
- Microsoft 365 Outage: Outlook, Teams and Copilot Down. What We Know
- Diwali Online Shopping Scams 2026: 10 Ways to Stay Safe
- 10 Best DDoS Protection Services for 2027
- 12 Best Web Application Firewalls (WAF) for 2027
- Best Ethical Hacking Tools in 2027: Free & Paid Picks
- Software supply chain attacks 2026: Timeline and developer checklist
- Binance Hack: $6.3 Billion Drained in the Largest Crypto Theft Ever. What We Know So Far
- This Site Uses XSLT Chrome Warning Explained: How to Fix It
Firstly, create a common file in the view folder. In this example, I have created a file name template.php in the /app/Views/ innerpages directory.
File structure:
/app/Views/ + innerpages - footer.php - header.php - template.php - home.php /app/Controllers - Home.php
Goto – template.php in Views
<?php
echo view('innerpages/header.php');
echo view($main_content);
echo view('innerpages/footer.php');
?>In the above example, $main_content is a dynamic view for each page.
Goto – header.php in Views
<!DOCTYPE html> <html> <head> <title><?php echo $title; ?></title> </head> <body>
Goto – footer.php in Views
<h1><?php $heading; ?></h1> </body> </html>
Goto – Home.php in Controllers
namespace App\Controllers;
use App\Controllers\BaseController;
class Home extends BaseController {
public function index() {
$data = [];
$data['title'] = 'Page Title';
$data['heading'] = 'Welcome to infovistar.in'
$data['main_content'] = 'home'; // page name
echo view('innerpages/template', $data);
}
}The $data[‘main_content’] = ‘home’; represents the home.php file of the Views directory, and it will be replaced by the $main_content variable in the template.php file.
Goto – home.php in Views
<h4> Welcome to Home </h4>



