[eluser]jedd[/eluser]
Read other people's code - there's no better way to learn (well, other than writing your own code). But yeah, picking up someone's code and analysing it, assuming you pick a smart person's code to start with, is an excellent learning experience.
There's no shortage of good demonstration code around, too. I hasten to add that my code is not, by any stretch of the imagination, good coode.
Quote:What happens now is that I get "Missing argument 2 for Prod:hoes()" + "Undefined variable: id" when url "prod/shoes/sandals/" is called, is just fully understable, but how can i get around it?
This is why you have default parameter values in your methods.
Consider .. somewhere in your Products controller ...
Code:
function shoes ( $type = FALSE , $id = FALSE ) {
if (! $type )
$type = 'sandals'; // Alternatively you'd set $type to a config entry you have for the default type or just die() here
if (! $id )
$id = 1; // Alternatively you'd set $id to a config entry you have for the default id or just die() here
}
Note that you can have your parameters in your method declaration set to, say : ($type = 'sandals', $id='1'). You'd do this if you don't care if wrong or absent information was in your URL, and were happy with a hard-coded default value. It's likely that an id of '1' doesn't match the category of sandals, though, so that probably isn't the best approach.
Don't take this the wrong way, but if you're having trouble with these things at the moment, you might want to put off remapping until you're more comfortable with the basic patterns.