Retrofitting App to use CodeIgniter |
[eluser]sophistry[/eluser]
oh great! i added a line of code to deal with GET queries. the view loading system was failing if faced with a GET query like this: http://example.com/photos.php?id=3 i want this to be as much of a drop-in solution as possible so i added code to handle that situation. to let those types of queries past CI you have to set a couple of config settings - that is detailed in the code comments on the wiki. cheers.
[eluser]sophistry[/eluser]
dc, i just noticed you are using the chdir() function in your modified code. i assume you are doing that because the CWD is actually the directory where CI starts off (where index.php is) rather than where the view is located. i think this is an interesting solution to potential path problems with old code in old sites that weren't designed to be "moved" to new locations. that is, pure relative paths in include() and require() calls get messed up. for instance, if you have a script with Code: include('separate_file_in_same_directory'); Code: include(REAL_LOCATION_OF_THIS_FILE.'separate_file_in_same_directory'); my only concern with using chdir() to the view file is that there may be other things the CI is doing after the $this->load->view() method that could potentially get confused if the CWD is changed. i am not sure about the implications, but i decided to solve the problem another way. instead of using chdir() to help old scripts scope themselves, i just went in a modified the scripts. however, your solution may be better in the long run. i'll try it out, but could you let me know if you get into any problems with chdir() yousrself? thanks.
[eluser]dcunited08[/eluser]
Quote:instead of using chdir() to help old scripts scope themselves, i just went in a modified the scripts. I have used it several times for different includes and requires and, so far, havn't had a problem. If I could go in and change every script, I would change it to use the library functions. The problem is with relative links here there and everwhere, there is no way for me to really do that. Say I have a file ./1.php and ./1/2.php and wanted both of them to look at ./1/3/2.php. They would need different includes from their relative locations, not something I would like to do with a search and replace. I put the second chdir in to return it to the original directory so that it does not have issues further down the line.
[eluser]sophistry[/eluser]
ah, a second chdir() after the first! how polite... thanks for elucidating. EDIT: how's this? EDIT2: removed conditionals on chdir() EDIT3: updated chdir() to use full server path to the file. EDIT4: here's the link to the wiki with the full code and comments: http://codeigniter.com/wiki/site_migrate/ Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |