![]() |
How do I retrieve a uri segment in a hook? - 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: How do I retrieve a uri segment in a hook? (/showthread.php?tid=32917) Pages:
1
2
|
How do I retrieve a uri segment in a hook? - El Forum - 08-09-2010 [eluser]Jelmer[/eluser] Just took a quick look into an old system dir and is_loaded() is a CI2.0 function, doesn't exist yet in CI1.7.2 (both are in common.php and are loaded very early). Did you try the uppercase version of load_class('URI') instead of load_class('uri')? How do I retrieve a uri segment in a hook? - El Forum - 08-09-2010 [eluser]Salvatore Formisano[/eluser] yeah, I tried that, I get a white screen in that case.. How do I retrieve a uri segment in a hook? - El Forum - 08-09-2010 [eluser]Jelmer[/eluser] Are you showing all errors? (like I posted in post #4) Because if "Fatal errors" are shown but load_class('URI') gives you a white screen that means that load_class('URI') gives you a lesser error then load_class('uri'). But without knowing what error it's still giving, it's impossible to tell what's wrong. EDIT: For example, if you have defined CURRENT_LANGUAGE already somewhere else and forgot to remove that - the second define( 'CURRENT_LANGUAGE', $lang) would throw a parse error which is not shown when error reporting is set to E_ERROR. So set your error reporting to E_ALL to find out what's going on, don't take a white screen for a worse error then a "fatal error" because it isn't. It's just not showing the lesser errors, even though it does crash on them. How do I retrieve a uri segment in a hook? - El Forum - 08-09-2010 [eluser]Salvatore Formisano[/eluser] Yeah I have Code: error_reporting(E_ALL); also when I have Code: define('CURRENT_LANGUAGE', 'en'); I don't get any error.. How do I retrieve a uri segment in a hook? - El Forum - 08-10-2010 [eluser]Jelmer[/eluser] I didn't mean it would have to be the define() statement, I used that as an example. Bottom line still is that errors don't show unless they're fatal or possibly unless they happen after something. I can't tell from this, you'll have to find the mistake. You might try placing a exit() statement directly after fetching the URI - if you see the output: that's not what goes wrong, if you don't that might be what causes the error. But without the actual error you still don't know why. Example: Code: // Change this How do I retrieve a uri segment in a hook? - El Forum - 08-10-2010 [eluser]Salvatore Formisano[/eluser] Heh, I've tried the example you wrote just now and I only get segment 1: (no $x value basically..) Thanks for the help anyway, much appreciated How do I retrieve a uri segment in a hook? - El Forum - 08-10-2010 [eluser]Jelmer[/eluser] Hmm, that means that it works but that the URI hasn't been parsed yet (and thus segment() returns FALSE). The result is that CURRENT_LANGUAGE is set to FALSE which probably causes the white-screen error later on (because it's expected to be a string). Here's another thing that might work in its stead: Code: $segment = substr( load_class('URI')->_parse_request_uri(), 1); How do I retrieve a uri segment in a hook? - El Forum - 08-10-2010 [eluser]Salvatore Formisano[/eluser] Yeah it finally worked! now my pick_language hook is: Code: <? and the get_route function which is use is Code: if ( ! function_exists('get_route')) thanks a lot for the help man! |