Welcome Guest, Not a member yet? Register   Sign In
Accessing models from custom library
#7

[eluser]jedd[/eluser]
I'm not sure if this helps - as I'm not entirely sure what your intent is, outside of reducing the line count in one of your controllers.

As an intermediary stage, you could move common functionality into private functions within the controller. I tend to shuffle all my private functions down to the bottom of my controllers, nicely sectioned off and labelled of course. This works for me because they tend to be verbose - often large arrays being set up, or rearrangements of arrays - while at the same time not requiring much subsequent re-visiting. Once you pull stuff out into functions, it becomes easier to work out whether those functions are better relocated to a helper, a library, or back into one of your models. In the short term it definitely reduces the size of the part of the file that you tend to be active in.

If you're doing this purely because your IDE doesn't lend itself to navigating a large file (though I concede 2,000 lines is pretty fat for a controller - what's the code:comment ratio in there anyway?) then I'd suggest this isn't the best rationale for doing a re-design - it'd be easier just to get a better IDE.

If the problem of changing some URL's is too daunting, then your design may have other problems (changing URL's should be fairly straightforward, particularly if you're considering this from a 'split the controller into two or three smaller controllers' perspective).

If you really want the answer to your OP, and you have already tried reading the CI Manual and doing what it suggests on the [url="http://ellislab.com/codeigniter/user-guide/general/creating_libraries.html"]Creating Libraries[/url] page - viz. the ol' $CI =& get_instance(); trick - and found that it doesn't work, then that's a whole new problem.

So -- did it work?


Messages In This Thread
Accessing models from custom library - by El Forum - 10-10-2009, 07:36 AM
Accessing models from custom library - by El Forum - 10-10-2009, 08:39 AM
Accessing models from custom library - by El Forum - 10-10-2009, 10:22 AM
Accessing models from custom library - by El Forum - 10-10-2009, 06:00 PM
Accessing models from custom library - by El Forum - 10-10-2009, 06:28 PM
Accessing models from custom library - by El Forum - 10-11-2009, 02:37 AM
Accessing models from custom library - by El Forum - 10-11-2009, 06:55 AM
Accessing models from custom library - by El Forum - 10-11-2009, 07:10 AM
Accessing models from custom library - by El Forum - 10-11-2009, 07:27 AM
Accessing models from custom library - by El Forum - 10-11-2009, 07:31 AM



Theme © iAndrew 2016 - Forum software by © MyBB