Welcome Guest, Not a member yet? Register   Sign In
Go to controller and filter by segment
#1

[eluser]IvanBlue[/eluser]
Hello, how can I go to my controller "shops" and make a filter with the next segment "clothes". The url goes like this "/shops/clothes" but when they're together a 404 Page Not Found error appears. When I pull out "clothes" and leave at just "/shops" it works perfectly, but I need the next segment to do the filter. How can I go to the controller and use the next segment as a filter expresion?

Thanks so much.
#2

[eluser]WanWizard[/eluser]
The next segment must be a method, so you need a method called 'clothes' in your shops controller.
#3

[eluser]IvanBlue[/eluser]
Yes, I see that, but the thing is I need the segment to be dynamic, so it could be "clothes" or whatever else. How can I achieve this? Thanks.
#4

[eluser]IvanBlue[/eluser]
I'm reading there's a way to do this using routing. How can I acomplish this using routing to send the segment to a method? Thanks.
#5

[eluser]IvanBlue[/eluser]
Solved! The usual pattern in segment is example.com/class/method/id/ so I can change the routes.php file so everything that gets after the class name is redirected to the appropriate method instead of being process inside index. I use a wildcard to do this:

Code:
$route['comercios/:any'] = "comercios/category";

It works perfectly ^_^
#6

[eluser]WanWizard[/eluser]
Alternative option is to use the _remap() method ( see the user guide ).

This allows you to capture all calls to your controller, regardless of the method requested. The first parameter of the _remap() call will contain the method requested.
#7

[eluser]Unknown[/eluser]
[quote author="WanWizard" date="1282400778"]The next segment must be a method, so you need a method called 'clothes' in your shops controller.[/quote]








so it could be “clothes” or whatever else. How can I achieve this? Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB