[solved - thanks!] $this->uri->rsegment(x) in a hook? |
[eluser]Tim Skoch[/eluser]
I'm trying to use the URI class in a pre-controller hook, but whenever I do, I get the following PHP error: Fatal error: Using $this when not in object context in /path/to/my/ci/installation/system/application/hooks/login.php on line 3 My call from within the hook is as follows: echo($this->uri->rsegment(1)); (bad form, I know, echoing output before headers are sent. But I'm just troubleshooting right now...) All I need to obtain is the first segment of the URI after it has been routed.
[eluser]xwero[/eluser]
To get the segments i suggest you use a post_controller_constructor hook because the super object isn't defined yet when executing pre_controller hooks. You can get the segments but then you have to use this Code: $URI =& load_class('URI'); edit : wiredesignz beat me
[eluser]Tim Skoch[/eluser]
Thanks guys! Your suggestion worked great. I've outlined what I was working on in the following post, hoping to attract some constructive criticism. Uber-simple login script... |
Welcome Guest, Not a member yet? Register Sign In |