Welcome Guest, Not a member yet? Register   Sign In
question concerning url parameters

Ok... so I want to have an url structure like this:


That's fine, but let's say that I got so much fruit that i need to use pagination.
I can use for example CI pagination class and work out a url like this:


In this case the third page would show.
One might think that there is no problem with this. But there is a problem, an url like the last one, with the meaningful content in the end, is a lot more search engine friendly.

I don't mind having links like:

but there's a quite good SEO advantage in using a simpler url for the first page:
instead of something like this:

Problem is:
if a controller function definition as the page number as a parameter, then it will throw an error if it's not present.

How can one make an url parameter optional?

[eluser]Colin Williams[/eluser]
$page_num = $this->uri->segment(6, 1);
// Returns 1 if there is no 6th segment

You could set a default parameter for your function.

function list ($type, $page = 1)

[eluser]Tom Glover[/eluser]
[quote author="ontguy" date="1218608298"]You could set a default parameter for your function.

function list ($type, $page = 1)

this is probably the best way to do it, because you can still reorder your url's at a later date with out breaking the rest of your code.

Dummy me, this is basinc PHP.
Thank you for the replies.

Theme © iAndrew 2016 - Forum software by © MyBB