Problems with uri routing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Problems with uri routing (/showthread.php?tid=5625) Pages:
1
2
|
Problems with uri routing - El Forum - 01-29-2008 [eluser]emperius[/eluser] I made a function in the helper for the information output depending on the url this helper is loaded automatically however when i try to get current segments in the url (like $this->uri->segment(1)) i get a bug: Code: Fatal error: Using $this when not in object context in is there any solution of the problem? Problems with uri routing - El Forum - 01-29-2008 [eluser]xwero[/eluser] in a helper you need to use Code: $ci =& get_instance(); Problems with uri routing - El Forum - 01-29-2008 [eluser]emperius[/eluser] thank you everything works however i don't really understand how it works. Could you please explain? Problems with uri routing - El Forum - 01-29-2008 [eluser]xwero[/eluser] the functions in helpers are not in a class they are loose functions like the native php functions. They don't belong to any class that is why you can use them everywhere. the $this-> variable is used to select a variable or a function, in a class called method, in the class or a parent class. Problems with uri routing - El Forum - 01-29-2008 [eluser]emperius[/eluser] thank you for your reply Problems with uri routing - El Forum - 01-29-2008 [eluser]Edemilson Lima[/eluser] I am having a problem with a routing... At my routes.php, I have: Code: $route['([a-z]+)/([0-9]+)'] = "$1/details/index/$2"; If I try to access something like: http://www.site.com/products/details/index/3 It works fine. But, if I do it by the route: http://www.site.com/products/3 It calls products/details/index, but does not send the id code: Code: A PHP Error was encountered "products" is a folder, "details" is the controller and "index" is its default function. Any ideas? Problems with uri routing - El Forum - 01-29-2008 [eluser]emperius[/eluser] try the easy way $route['details/:num'] = "details"; Problems with uri routing - El Forum - 01-29-2008 [eluser]Edemilson Lima[/eluser] I think it should be: Code: $route['products/:num'] = 'products/details'; I did try this too, but it doesn't work. Anyway, it should work with a regexp. Problems with uri routing - El Forum - 01-29-2008 [eluser]wiredesignz[/eluser] I think theres a bug here? I had the same problem. uri->rsegment[2] gets dropped if you route into a controllers sub-directory See line #224 - system/codeigniter/CodeIgniter.php Problems with uri routing - El Forum - 01-29-2008 [eluser]Edemilson Lima[/eluser] This line? Code: /* Or the new version at the SVN? |