![]() |
Invoking CodeIgniter from outside of CI (or on non-CI based sites), loading views - 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: Invoking CodeIgniter from outside of CI (or on non-CI based sites), loading views (/showthread.php?tid=23783) |
Invoking CodeIgniter from outside of CI (or on non-CI based sites), loading views - El Forum - 10-21-2009 [eluser]besson3c[/eluser] Hello, I wish to pull in all of the CodeIgniter functions from outside of CI for two reasons: - allows me to write shared CI-based libraries/views in non CodeIgniter sites - allows me to make AJAX calls to files not being redirected to CodeIgniter via mod_rewrite, and to speak in CodeIgniterese within these libraries. So far, I have accomplished this via the following: Code: <?php the "mycisite" CI site has all of my shared libraries and stuff that I need available outside of CI. This actually works fine. My problem is, I cannot load views from the mycisite centralized CI site this way. Tracing this, I can see that with logging enabled and outputting the contents of the output buffer within system/libraries/Loader.php that it is not picking up the contents of the view for some reason. It just seems pretty confused about being invoked this way, and I haven't really pinpointed why and how. As a work-around, I can simply simulate the load->view functionality by running an extract of my data object, and doing an old-fashioned include. However, for whatever reason running an include creates extra spaces in between tags which messes up some of my views. My workaround: Code: <?php All of this works too, but this is a little ugly and terribly confusing. My questions: 1) Is there a way to run a $this->load->view on a CodeIgniter site initialized by a PHP script including the site's index.php file? (i.e. on a non-CI site hacked to load all of the CI internals as per my first block of code, above) 2) Why does running an include statement from within a view produce extra whitespace? I know that this is pretty odd. Believe me, I've spent a considerable amount of time mulling over a better way to go about this. My setup is pretty complicated, I have backwards compatibility with non-CI sites to contend with, which introduces a fair amount of complexity. For the sake of helping me, try to humor me that I have a reason for going about this this way ![]() |