Changing URL information without changing the code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Changing URL information without changing the code (/showthread.php?tid=20370) |
Changing URL information without changing the code - El Forum - 07-07-2009 [eluser]Rubiz'[/eluser] Hello everyone I wanna know if there is some way to replace de ID, in URL, for the slug of the news, without changing the original code. Today I have this: www.website.com/index.php/news/1234 << this is de ID. I have, without changing CI code, this: www.website.com/index.php/news/title-of-the-new It is possible? Changing URL information without changing the code - El Forum - 07-07-2009 [eluser]Phil Sturgeon[/eluser] Well you cant change what the code does without changing the actual code, its impossible. You can probably keep your controllers/views the same and just change the field within the model. Code: $this->db->where('id', $id); becomes Code: $this->db->where('slug', $id); Tada. Changing URL information without changing the code - El Forum - 07-07-2009 [eluser]Rubiz'[/eluser] I have asked here cause I have a friend with the same problem, and he could do this, the difference is that he was working with C#/.NET Changing URL information without changing the code - El Forum - 07-07-2009 [eluser]Gordaen[/eluser] You can update your code to easily accept an id or a slug (or either), but if it's set up to accept an id only, you'll have to change it to accept a slug. |