user1765862
user1765862

Reputation: 14145

best way to organize layout page, or multiple include views using one page

Which approach would you recommend me to use in building "Layout" or "Master" page in CodeIgniter.

Should I create master page view like this

<div id="page">
    <div id="header"><?php include "_header.php"?>
    </div>
    <div id="content"><?php echo $content ?>
    </div>
    <div id="footer">
       <?php include "_footer.php"?>
    </div>
</div>

_header.php

<?php echo $title ?>

and controller which sends data

function displayData()
{
   $data['title'] = "some title";
   $data['content'] = "content page";
   $this->load->view('header');
   $this->load->view('content', $data);
}

or you use some other technique, I'm coming from asp.net mvc world so I'm trying to grab fast as possible some tips.

Thanks

Upvotes: 2

Views: 278

Answers (1)

Ben Branyon
Ben Branyon

Reputation: 172

Codeigniter has a layout library. You can access it here https://github.com/EllisLab/CodeIgniter/wiki/layout-library.
Also, you can approach layouts in Codeigniter using hooks.

Upvotes: 1

Related Questions