• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing URL information without changing the code

#1
[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?

#2
[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.

#3
[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

#4
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.