Hello, I really need some help in creating some URL rules.
I have a route : product/list, where I show a list of models, let’s say Products (think notebooks), that can be filtered. So, having Brand and Memory size as filters, my URL would look like :
http://www.mywebsite.com/product/list?brand=1,2&memory=8,16&order=price asc
Shows all products that have brand IDs 1 and 2 and memory size 8 and 16. As you can see, I also added an order by param. All these filters are dynamic, so one time, I could have only the memory param, or only the order param, or 2 of these.
So, one way to make URL rules would be to write multiple rules, but that means I have to write a rule for each combination of params.
'products/<brand:\d+>/<memory:\d+>' => 'product/index' //for brand and memory size
'products/<brand:\d+>' => 'product/index' //for brand only
//... and so on, for every possible combination, gets more complicated by having more than 3 params.
Anyway it can be simpler than this ? Or, if I do write all the rules, will there by severe performance problems ?
I’m looking for a way of writing just one rule, that can take params that might be there or not.
I found this, but it is not working http://www.yiiframework.com/forum/index.php/topic/35616-yii-url-rules-optional-parameters/
PS : I know that my regex don’t work right now, cause \d+ only matches decimals, I will have to look into how to match comma separated id’s.