[eluser]Harvard725[/eluser]
Hello CodeIgniters....
I want to create an array in a CONTROLLER, send it to my VIEW and then use a function to iterate through the array, displaying each element as a link.
Here's the CONTROLLER code...
=======================================
class Footer extends Controller {
function index()
{
$this->load->helper('url');
$data['linkA'] = anchor('welcome','Main Page',array('class' => 'lnkA'));
$data['linkB'] = anchor('news','News',array('class' => 'lnkA'));
$data['linkC'] = anchor('shop','Store',array('class' => 'lnkA'));
$data['linkD'] = anchor('about','About Us',array('class' => 'lnkA'));
$data['linkE'] = anchor('contact','Contact Us',array('class' => 'lnkA'));
$this->load->view('vfooter',$data);
}
My goal is to allow as little PHP code in the VIEW as possible... Every time I pass the $data array to the VIEW and attempt to iterate I get an "UNDEFINED VARIABLE data" error messsage... I can echo an associative array without a problem but I'd rather call a function that returns a value so that I can put <?php =$txtLinks ?> in the VIEW and have them appear. Another question... Do I put the function in a MODEL?
Thanks for any help or suggestions...