user7931042
user7931042

Reputation:

How to display an html file between header and footer in PHP and CodeIgniter

                <?php
                defined('BASEPATH') OR exit('No direct script access allowed');
                //error_reporting(0);
                $this->load->view('layouts/topmenu.php', $metaData);
                //echo $emailid;
                //exit;
                ?>
                //I would like to display an HTML file here
                 <a href=""></a>
                <?php $this->load->view('layouts/bottom'); ?>
                <?php $this->load->view('layouts/footer'); ?>

I want to display a header and footer page with an html file in between them which is in a .html file.

How do I display the .html file in the PHP code ?

Upvotes: 0

Views: 80

Answers (4)

Brad
Brad

Reputation: 1691

1st, you only send views through your controller. NOT through another view. You should show your controller and what your metadata is

public function Page() {
 $this->load->view('layouts/topmenu.php', $metaData);
 $this->load->view("file.html");
 $this->load->view('layouts/bottom');
 $this->load->view('layouts/footer');
 }

Upvotes: 0

PHP Geek
PHP Geek

Reputation: 4033

load same as header footer and use html extention too with file name.

Upvotes: 0

Javier Larroulet
Javier Larroulet

Reputation: 3237

One of the good things of Codeigniter is that this is quite easy to do and has multiple ways to do it

Since it looks like the problem is that the view you need to call is an html file instead of a php file, all you need is to place the html file in your views directory and load it specifiying the filename extension:

$this->load->view('layouts/file.html');

That's all there is to it really

Upvotes: 3

bhooks
bhooks

Reputation: 419

You can utilize the PHP function include which will pull the contents of another file into your PHP script when it runs.

include('file.html');

Upvotes: 0

Related Questions