Problem working out how to make $CI->$variable work - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Problem working out how to make $CI->$variable work (/showthread.php?tid=33230) |
Problem working out how to make $CI->$variable work - El Forum - 08-19-2010 [eluser]J Maxwell[/eluser] I have searched a bit for this, but strugging to work out how to achieve what I want. I am querying a database, then dynamically loading assets based on the results of the query. However, I need to do something like this: Code: foreach ($w as $widget) : The problem with this is it keeps throwing member function on non-object errors. How do I refer to the widget I just created without being able to type the name in? Cheers, John Problem working out how to make $CI->$variable work - El Forum - 08-19-2010 [eluser]WanWizard[/eluser] Does your $this->load->widget() method assign the new class to the CI object? Something simple as this would do it: Code: $CI =& get instance(); Problem working out how to make $CI->$variable work - El Forum - 08-19-2010 [eluser]J Maxwell[/eluser] Hey, thanks for that, I was sure there was a pretty simple explanation and I'd spent long enough staring blankly at the screen that I wasn't going to get it! Problem fixed, many thanks. John |