Master Page with Template Library

In Web site development, the master page is a feature that enables you to define common structure and interface markup elements for your Web site, including headers, footers, style definitions, or navigation bars.

The master page can be shared by any of the pages in your Web site, called the Content Page, and removes need to duplicate code for shared elements within your Web site.

The Template Library

The Template Library is the best library I have stumbled upon regarding master pages.

Installating Template Library

Download the library here and just copy its contents in your site.

Autoload the library

You are going to use the masterpage library a lot so, autoload it to make things easier.

Prepare the masterpage view


Calling the masterpage from a controller

If you want to call the masterpage from a controller, it’s easy:

$data['title'] = 'test title';
$this->template->write_view('header', 'template/header_view', $data, TRUE);
$this->template->write_view('content', 'home_view', $data, TRUE);
$this->template->write_view('footer', 'template/footer_view', $data, TRUE);


Post A Comment

Anti-Spam Quiz: