Problems with uri routing |
[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?
[eluser]xwero[/eluser]
in a helper you need to use Code: $ci =& get_instance();
[eluser]emperius[/eluser]
thank you everything works however i don't really understand how it works. Could you please explain?
[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.
[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?
[eluser]emperius[/eluser]
try the easy way $route['details/:num'] = "details";
[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.
[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
[eluser]Edemilson Lima[/eluser]
This line? Code: /* Or the new version at the SVN? |
Welcome Guest, Not a member yet? Register Sign In |