Welcome Guest, Not a member yet? Register   Sign In
How to do a page title rather than a page id?
#1

[eluser]hcker2000[/eluser]
I have been working with codeigniter for a while now and I love it so much. Normally I do some thing like http://www.mysite.com/cms/page/1 but now I am wanting to do some thing like http://www.mysite.com/cms/page/codeigniter review.

Could any one help me achieve such a system? I find it kind of hard to think that people are using the text "codeigniter review" in a db query so I think it has some thing to do with the .htaccess and mod_rewrite.
#2

[eluser]umefarooq[/eluser]
if you want to make your url text use a column in you table name seo_url save seo url in you table like id then you can query that keyword from your table to get you desired page.

then your url will be like http://www.mysite.com/cms/page/codeigniter-review

to make url title
Code:
url_title(string);

save only this part in table codeigniter-review
#3

[eluser]hcker2000[/eluser]
That could work. I just want to try and keep performance good and I have heard that with mysql a text based unique id look up is slower than if it is just a number.
#4

[eluser]Flemming[/eluser]
I'm not an expert but I think it's unlikely you'd notice any difference in speed if you're only looking up a single row. You should probably leave your unique id as the primary key (may be useful for admin/editing etc) and add another column to the table 'slug' (http://codex.wordpress.org/Glossary#Slug) which contains your friendly url. Then compare the time it takes (profile your application) getting the page from the DB by id, then by name (slug). I'd be interested to know if you find it any slower using the page name?
#5

[eluser]n0xie[/eluser]
Obviously using an id will be much much faster.

For one, the id is the primary key, thus it's indexed.
Two, search for an integer is much faster than search for a var_char.

Not that you will notice the difference. We're talking order of miliseconds here.
#6

[eluser]hcker2000[/eluser]
thanks I think info you have all given should give me a good place to get this started. Thanks.
#7

[eluser]BrianDHall[/eluser]
One more - the way I do it is just to use a simple trick.

I use the ID, but then to make it prettier I tag on the article name. So for instance you have mysite.com/controller/function/1/my_genius_article.html

Nothing after the id of 1 matters to CI, but I use it for SEO optimization. Sometimes I add all kinds of crap in there for SEO, but the upside is you don't have to do Anything different to make it work.

It also allows you to produce short-urls easily if you need to by just manually trimming off the extra bits, or automatically by using your own function to spit out only the absolutely necessary piece of url.
#8

[eluser]Eric Cope[/eluser]
you can add an index for the slug too.




Theme © iAndrew 2016 - Forum software by © MyBB