Optional URL fragment in Codeigniter?
- by DA
This is maybe a simple syntax question or possibly a best-practices question in terms of codeigniter.
I should start by saying I'm not a PHP or Codeigniter person so trying to get up to speed on helping on a project.
I've found the CI documentation fairly good. The one question I can't find an answer to is how to make part of a URL optional. An example the CI documentation uses is this:
example.com/index.php/products/shoes/sandals/123
and then the function used to parse the URI:
function shoes($sandals, $id)
For my example, I'd like to be able to modify the URL as such:
example.com/index.php/products/shoes/all
So, if no ID is passed, it's just ignored. Can that be done? Should that be done?
A second question unrelated to my problem but pertaining to the example above, why would the variable $sandals be used as in the example, the value is 'sandals'? Shouldn't that variable be something like $shoetype?