.htaccess - Yii custom url routing -
i want create friendly urls in yii framework.
an example:
mysitename.com/country/city/travelling-type
or
mysitename.com/country/city/travelling-type/price mysitename.com/city/price
etc.
the problem confuses parameters. tried solve below code, not enough:
'urlmanager' => array( 'urlformat' => 'path', 'appendparams' => true, 'showscriptname' => false, 'usestrictparsing' => false, 'rules' => array( '<country:\w+>/<city:\w+>/<travelling_type:\w+>/<accommodation:\w+>/<caftering:\w+>/<price_from:\d+/<price_to:\d+>' => 'travels/list' ), ),
its not easy since yii doesn't know difference between 2 urls:
mysitename.com/{city}/{price} mysitename.com/{city}/{accommodation}
what can though change route system:
'<param1:\w+>/<param2:\w+>/<param3:\w+>/<param4:\w+>/<param5:\w+>/<param6:\d+/<param7:\d+>' => 'travels/list'
your action have identify query parameter represents parameter search query. in instances in system, should easy enough. example, there's limited number of countries, there's limited number of traveling types, etc.
i.e.
in case of
mysitename.com/{city}/{accommodation}
your system query "param1" (= city) against list of countries, cities, traveling types, accomodation types , catering types determine param1 indeed city. proceed param2 determine defines accomodation.
prices easier identify because different data types (in case of traveling search engine integer enough), can identify prices checking if price integer (or similar). differentiate price_from , price_to suggest assume if there's 1 price, it's price_from; if there's 2 prices, first price_from, second price_to. if want set price_to, set price_from 0.
i hope covers want do. can quite complicated set up, that's price have pay url route that. :)
Comments
Post a Comment