Welcome Guest, Not a member yet? Register   Sign In
Using CI with/without autoload - to fetch AJAX data
#1

[eluser]Ki[/eluser]
I have had a great time setting up my website with CI. Everything works well... however I cam to a point where I use ajax to get data on main page from another page using AJAX. To stramline the site, is there a way to use codegniter without the autoloading that is used in all of the site?
Example:
I use uri_helper, language files and a lot of helpers in most of the pages so they are autoloaded. However, if I want to create an RSS webpage, I do not need all of that autoloading, but I still want to use CI Active Record to fetch data for RSS page. How can I "bypass" autoloading to speed up the site and on a particular page just load CI database class? (I know how load a class...). My concern is that if I create controller RSS externds Controller - that would also trigger all the autoloads that I don't need?
#2

[eluser]BrianDHall[/eluser]
To get the functionality you want you need to remove autoloading entirely, and instead load your desired libraries (and such) via $this->load functionalty. This should be handled in a controller either in a function or in a constructor.

So for instance your Main controller constructor loads all your helpers and goodies and such, and then you have an Thin controller that loads nothing at all. Your autoload would then contain only things you need absolutely everwhere,.

There is no way to bypass autoloads defined in autoload.php per controller, because autoloading is performed too early to interupt.

Important caveat: You might find that the performance difference is so minor that you just don't care, but depending on application scale and just what all you autoload you might need to take this slightly more careful approach of loading a library only when you are pretty well sure to need it, or only when something is very very light.




Theme © iAndrew 2016 - Forum software by © MyBB