• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calling models from helpers

#1
[eluser]surfgatinho[/eluser]
Is there any way of calling functions in models from a helper?

Or alternatively, what would be the best way of having some code (for a dynamic menu) accessible by lots of different controllers?

Thanks,
Chris

#2
[eluser]Seppo[/eluser]
1) if you load the helper, the functions will be available in every place

2) you can extend your controller class defining a library MY_Controller or using a hook

#3
[eluser]ReGeDa[/eluser]
Code:
$CI = &get;_instance();
$CI->load->model('Something');
$CI->Something->do();

#4
[eluser]surfgatinho[/eluser]
Perfect! Thanks ReGeDa.

The first line did throw an error in Hebrew (!!!) with the semi-colon in:

Parse error: syntax error, unexpected ';', expecting T_PAAMAYIM_NEKUDOTAYIM in D:\WebSites\SilverMine\system\application\helpers\cart_helper.php on line 5

#5
[eluser]ReGeDa[/eluser]
it's problem of forum post. you can try it by yourself. write in form post "&get;_instance();" without ';' and you will have with ';'
Code:
&get;_instance();

#6
[eluser]wiredesignz[/eluser]
Hint: Use &/amp/; minus the slashes ie:

&get_instance();

Sorry, doesn't work in code blocks. Sad


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.