I have urls like this
example.com/model/id
example.com/image/123 (default rules)
I would rewrite it to:
example.com/category/123-this_is_encoded_title.html
My image model have following attributes:
- id
- title
- category
…
I need to add category from model to url.
How can i add category name dynamic to the url?
it seems that you already using some default CUrlManager rules.
Add below rule at top of your rule list. (I am assuming your controller id is image)
besides this, you have to change url creation in all places. You have to pass title and category values as the url params.
ex:
This answer explains what you need to do.
Please follow the @dInGd0nG suggestion for code re-factoring.