Welcome Guest, Not a member yet? Register   Sign In
friendly url
#1

[eluser]Thiago Leao[/eluser]
Hi guys, I am wanting to use friendly url on my site, but I have some doubts!!!!

On my site I have the following link: http://www.mysite.com.br/News/see News/7988e26df3862a959ce5e85703ff72fd

Class News
Method seeNews
Id 7988e26df3862a959ce5e85703ff72fd

In place of the ID, I would like to pass the title of the news.

Another thing I want: http://www.mysite.com.br/category/index/...58b9f758fb

this link is the User, wanted to change www.mysite.com.br/login

thanks
#2

[eluser]rana[/eluser]
use title. no problem. but in that case, in database, 'title' field should be marked as 'unique' to avoid duplicate entry with same title.

http://www.mysite.com.br/News/seeNews/{$titile}

Now in your "seeNews" function, you will need to to compare/retrieve data with checking against the 'title' field in db instead of 'id' field.

Please explain details about your second inquiry..
#3

[eluser]Thiago Leao[/eluser]
Hana Hi, thanks for your reply!
But that will not solve my problems.

I need to use FRIENDLY URL!

thanks!
#4

[eluser]rana[/eluser]
I think, I gave you the exactly that solution. You mentioned you wanted the title on url instead of long ugly id. What I suggested will solve it very well. otherwise, can you please show an example how you want it?
#5

[eluser]Thiago Leao[/eluser]
Already in the title I want.
thanks again!
#6

[eluser]Thiago Leao[/eluser]
Anyone?
thanks!
#7

[eluser]Otemu[/eluser]
Hi Thiago,

rana has already given you the solution to this problem but maybe you don't quite understand.

What you need to do is something like this
Code:
<?php
class News extends CI_Controller {

    public function seeNews($friendurl)
    {
        //here you run a query - send to the model
        //if there is a match in your database matching the friendly url then the results are returned to the controller stored in a array
        //send the array data to the view
       //now if someone goes to url http://www.mysite.com.br/News/see News/thisismynewspage
      // as long as you have matching title in your database the page will load, if not a match then you need to return 404 not found
    }
}
?>

Check out the guide here for more info

#8

[eluser]CroNiX[/eluser]
I'm not sure what the difference would be between passing the unique article ID, or passing the unique title. It's the same thing. Instead of searching the db for the unique ID, you'd just search for the title instead. So maybe you can be more clear on what the problem is?
#9

[eluser]bluelomo[/eluser]
Your news id is a GUID?

why don't give a friendly domain each news?





Theme © iAndrew 2016 - Forum software by © MyBB