Welcome Guest, Not a member yet? Register   Sign In
Creating Search Engine Friendly URLs
#1

[eluser]ajushi[/eluser]
Hi, I'm a newbie with CodeIgniter and I'm wondering, what's the suggested way of creating SEF URLs?

Thanks in advance!
#2

[eluser]Johan André[/eluser]
the url_title() in the url-helper is the way to go (most times).
#3

[eluser]ajushi[/eluser]
If the format is http://localhost/controller/function/parameters how do I got about coding the title of let's say the entry for a CI blog?
#4

[eluser]Johan André[/eluser]
Code:
$slug = url_title('The title of the post'); // Becomes the-title-of-the-post
#5

[eluser]ajushi[/eluser]
I mean, do I make the entry title as a parameter?
Johan, what do I do with $slug as you suggested?
#6

[eluser]Johan André[/eluser]
This is really the basics (which is covered in the user guide).
I suggest you watch the blog-tutorial too.

Basically you do this:

Save the title and slug to database.
Look up the slug instead of id when displaying posts.

I'm not going to write out the code for you. You need to put that together yourself.
Once you get the basics of application-flow and MVC there will be no problem.
#7

[eluser]Mikle[/eluser]
[quote author="Johan André" date="1250796912"]
Basically you do this:

Save the title and slug to database.
Look up the slug instead of id when displaying posts.
[/quote]

And how about perfomance if there are 2000+ posts in blog?
#8

[eluser]Johan André[/eluser]
[quote author="Mikle" date="1250797308"][quote author="Johan André" date="1250796912"]
Basically you do this:

Save the title and slug to database.
Look up the slug instead of id when displaying posts.
[/quote]

And how about perfomance if there are 2000+ posts in blog?[/quote]

Well, creating an index?
And I don't think looking up the slug (instead of id) is gonna have a huge impact of performance...

Afaik, there is no other way to do it...
#9

[eluser]Mikle[/eluser]
[quote author="Johan André" date="1250797458"][quote author="Mikle" date="1250797308"][quote author="Johan André" date="1250796912"]
Basically you do this:

Save the title and slug to database.
Look up the slug instead of id when displaying posts.
[/quote]

And how about perfomance if there are 2000+ posts in blog?[/quote]

Well, creating an index?
And I don't think looking up the slug (instead of id) is gonna have a huge impact of performance...

Afaik, there is no other way to do it...[/quote]

Index of varchar(255)? Hmm...
And how about md5($slug)?
#10

[eluser]Dam1an[/eluser]
[quote author="Mikle" date="1250797308"]And how about perfomance if there are 2000+ posts in blog?[/quote]

It's not going to be a problem, even without an index
I'm doing lookups by slug on a table with 70,000+ rows and there's no added delay compared to ID lookups




Theme © iAndrew 2016 - Forum software by © MyBB