Skip to content

Instantly share code, notes, and snippets.

@kirasiris
Created December 5, 2017 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kirasiris/d0f477373a8ef3bf3e27d5d0cfc2552b to your computer and use it in GitHub Desktop.
Save kirasiris/d0f477373a8ef3bf3e27d5d0cfc2552b to your computer and use it in GitHub Desktop.
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Template
{
var $ci;
function __construct()
{
$this->ci = & get_instance();
}
/*
* @name: load
* @desc: Loads the template and view specified/ Carga el template y el view especificado
* @param:loc: Location/ Locacion (admin or public)
* @param:tpl_name: Name of the template/ Nombre del template o layout
* @param:view: Name of the view to load/ Nombre del view a ver
* @param:data: Optional data array/ Array con valores opcionales
*/
function load($loc, $tpl_name, $view, $data = null)
{
if ($loc == 'admin' && $tpl_name == 'default') {
$tpl_name = 'admin';
}
if ($loc == 'public' && $tpl_name == 'default') {
$tpl_name = 'public';
}
$data['main'] = $loc . '/' . $view;
$this->ci->load->view('/templates/' . $tpl_name, $data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment