Last active
January 4, 2016 07:59
-
-
Save gpedro/8591888 to your computer and use it in GitHub Desktop.
Codeigniter Template Library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Layout { | |
public function render($view, $args = array()) | |
{ | |
$CI =& get_instance(); | |
$CI->load->helper('file'); | |
if(get_file_info(APPPATH.'views'.DIRECTORY_SEPARATOR.$view.'.php') == false) | |
{ | |
die('Layout Library: view não encontrada.'); | |
} else { | |
$CI->load->library('parser'); | |
$CI->load->helper('url'); | |
$CI->load->config('site_config'); | |
$layout = (@$args['layout']) ? $args['layout'] : '01_layout'; | |
$data = array(); | |
$data['custom_js'] = (isset($args['custom_js'])) ? $args['custom_js'] : ''; | |
$data['custom_css'] = (isset($args['custom_css'])) ? $args['custom_css'] : ''; | |
$data['title'] = (isset($args['title'])) ? $args['title'].' | ' .$CI->config->item('site_name') : $CI->config->item('site_name').' | ' .$CI->config->item('site_slogan'); | |
$CI->parser->parse('template/header', $data); | |
$data['fb_login'] = (isset($args['fb_login'])) ? $args['fb_login'] : ''; | |
ob_start(); | |
$CI->parser->parse($view, $args); | |
$data['content'] = ob_get_contents(); | |
ob_end_clean(); | |
$CI->parser->parse('template/'.$layout, $data); | |
$CI->parser->parse('template/footer', $data); | |
} | |
} | |
} | |
/* End of file layout.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment