[eluser]wdcci[/eluser]
I am still having a problem with this. My PHP skills are fairly undeveloped, so bear with me.
I have a library called Includes that contains the following:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Includes {
function footer_find_merchants()
{
$CI =& get_instance();
$CI->load->model('includes_model');
$data['retail'] = $CI->includes_model->find_categories(1);
$data['consumer'] = $CI->includes_model->find_categories(2);
$data['resturant'] = $CI->includes_model->find_categories(3);
$data['professional'] = $CI->includes_model->find_categories(4);
return $data;
}
}
?>
This class is automatically loaded in the autoload.php file.
Inside my view I try and call the the function with the following:
Code:
<?php print $this->includes->footer_find_merchants(); ?>
I get the following error when I run the page:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: retail
Filename: includes/footer.php
Line Number: 21
(Line 21)
Code:
<?php foreach ($retail->result() as $row): ?>
<li><a >url; ?>" target="_blank"><?php echo $row->merchant_name; ?></a></li>
<?php endforeach; ?>
I understand something is off, i'm just not sure how to fix it.
When i add
Code:
$data = $this->includes->footer_find_merchants();
$this->load->view('home_index',$data);
to my controller, it works just fine. This defeats what I'm trying to do. I would like to just call the function from the footer that way I have just once maintain the code form the libray, the footer view and my model. Any help would be great. Thanks.