Codeigniter URL Pattern using htaccess / route / model |
I've just put my hands on MVC and new to Codeigniter.
As per my understanding Codeigniter url consist of (base url) / Class / Method I am trying some more complex url structure as base_url/listing/category/country/state/city/listing-id-23 which I presume can be achieved by calling another controller from another, or may be using route. PS, category/country/state/city here changes dynamically based on product. Is it possible to have url like that with Codeigniter or do I have to stick with www.example.com/listing/listing-id-23 ? Thanks you.
Yes, you can have an URL like that. How is up to you.
An option is to use the _remap method Add this to your controller PHP Code: public function _remap($method) { What this does is override the default behavior of how CI calls methods. When this method is available within the called controller this is the first method called. From here you can route to any other method within the called controller. If you want controllers calling controllers how should look into HMVC But if you are new to MVC and CI I would advise getting to know the basics first. Hope this helps you on your way |
Welcome Guest, Not a member yet? Register Sign In |