[eluser]The Beginner[/eluser]
Quote:Show the code sections for:
o controller, where you set your header_logo variable,
o controller, where you call the view,
o view, where you use the header_logo variable.
Ok, first the controller loading data:
Code:
$this->db->where('wp_header_active', '1');
$querydata = $this->db->get('wp_header_data');
if ($querydata->num_rows() > 0):
{
foreach($querydata->result() as $row):
{
$data['header_logo'] = snappy_image($row->wp_header_logo, 'My Picture', 'somestyle');
$data['title'] = $row->wp_header_name;
$data['site_name'] = $row->wp_header_name;
}
endforeach;
}
endif;
$querydata->free_result();
$this->template->set('title', $data['title']);
$this->template->set('header_logo',$data['header_logo']);
// Load the template
$this->template->load('template', 'wpHeader');
This is my template.php, the plan is to load my header view, menu view contents and then my footer.
Code:
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<div id="header"><?php echo 'header'; ?></div>
<div id="menu"><?php echo 'menu'; ?></div>
<div id="contents"><?php echo $contents; ?></div>
<div id="footer"><?php echo 'footer'; ?></div>
</body>
</html>
Now the view:
Code:
<?php
echo $header_logo;
?>
And that is it...... the error I get is :
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: header_logo
Filename: views/wpHeader.php
Line Number: 2