![]() |
id replace the url - 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: id replace the url (/showthread.php?tid=29745) |
id replace the url - El Forum - 04-20-2010 [eluser]cmarra[/eluser] Hello, how can I sotituire id in a url like example.com/index.php/products/shoes/show/123 with a name of a file? for example if 123 is the id of a file, I can make the URL example.com/index.php/products/shoes/show/guide_php id replace the url - El Forum - 04-20-2010 [eluser]pickupman[/eluser] Similar to how must CMS systems work. Pass the parameter to your function, lookup "slug" (filename) in database for the file / file id, and handle accordingly. You could use a regular expression to make it work for either or. Code: function shoes(){ id replace the url - El Forum - 04-20-2010 [eluser]cmarra[/eluser] maybe I did not understand your answer but I try to explain better: for example in this case http://www.voices.com/people/MichelleFalzon "People" is the controller and "MichelleFalzon" is the resource or other parameter that is passed to the controller which then will return the resource ... I would do the same thing .... how can I proceed side code? id replace the url - El Forum - 04-20-2010 [eluser]pickupman[/eluser] Yes you would do the same as the example I provided above. You are just looking a name rather than a id for a record in the DB. You will just have to make sure that a name cannot be entered twice, otherwise the second record wouldn't be accessible. id replace the url - El Forum - 04-20-2010 [eluser]cmarra[/eluser] Maybe I have to work with custom remap URL by URL routing? id replace the url - El Forum - 04-20-2010 [eluser]pickupman[/eluser] My apologies, I hadn't notice that you were giving another example with a different number of segments. You would use a route like: Code: $routes['people/(:any)'] = 'people/function/$1'; id replace the url - El Forum - 04-20-2010 [eluser]cmarra[/eluser] And what would this rule? |