I got a really newbie question related to templating… here we go:
I got a library called Template here is the code… (actually i find this code in some tutorial and i am using it, if anyone got a better one share it please =D)
class Template {
protected $CI;
var $template_data = array();
function __construct()
{
$this->CI =& get_instance();
}
function set($name, $value)
{
$this->template_data[$name] = $value;
}
function load($template = '', $view = '' , $view_data = array(), $return = FALSE)
{
$this->set('contents', $this->CI->load->view($view, $view_data, TRUE));
return $this->CI->load->view($template, $this->template_data, $return);
}
}
In my views folder i got a folde called templates with all my templates…
I will post my templates/site.php code here so you guys can understand what i am talking about…
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Home</title>
<!-- Meta
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<!-- Styles e Icone -->
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/css/styles.css" />
<link rel="shortcut icon" type="image/ico" href="" />
<!-- Javascript -->
[removed][removed]
</head>
<body id="<?php if($this->uri->segment(1)){ echo 'internas'; } else { echo 'home'; } ?>">
<div id="header" class="clearfix">
<?php $this->load->view('includes/header'); ?>
</div>
<div id="contents">
<?php echo $contents; ?>
</div>
<div id="footer">
<?php $this->load->view('includes/footer'); ?>
</div>
</body>
</html>
As you notice, i got a folder called includes inside views and got a header.php inside this folder…
My question is, how can i pull some database data in the header.php?
Maybe its a little bit confusing but i hope you guys can understand my question
Cheers! Thanks for helping
