![]() |
[solved - thanks!] $this->uri->rsegment(x) 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: [solved - thanks!] $this->uri->rsegment(x) in a hook? (/showthread.php?tid=12296) |
[solved - thanks!] $this->uri->rsegment(x) in a hook? - El Forum - 10-13-2008 [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. [solved - thanks!] $this->uri->rsegment(x) in a hook? - El Forum - 10-13-2008 [eluser]wiredesignz[/eluser] Code: $URI =& load_class('URI'); [solved - thanks!] $this->uri->rsegment(x) in a hook? - El Forum - 10-14-2008 [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 ![]() [solved - thanks!] $this->uri->rsegment(x) in a hook? - El Forum - 10-14-2008 [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... |