Welcome Guest, Not a member yet? Register   Sign In
Dynamic Footers
#7

[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; ?&gt;" target="_blank">&lt;?php echo $row->merchant_name; ?&gt;</a></li>
               &lt;?php endforeach; ?&gt;


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.


Messages In This Thread
Dynamic Footers - by El Forum - 08-09-2008, 05:18 PM
Dynamic Footers - by El Forum - 08-09-2008, 06:00 PM
Dynamic Footers - by El Forum - 08-09-2008, 06:47 PM
Dynamic Footers - by El Forum - 08-09-2008, 09:24 PM
Dynamic Footers - by El Forum - 08-09-2008, 10:36 PM
Dynamic Footers - by El Forum - 08-09-2008, 10:37 PM
Dynamic Footers - by El Forum - 08-10-2008, 08:00 AM
Dynamic Footers - by El Forum - 08-10-2008, 01:58 PM
Dynamic Footers - by El Forum - 08-10-2008, 04:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB