Problem In Hiding Parameters From Url

Hi,

I want to hide the parameters from url. I create the url by using createUrl as Yii::app()->createUrl('/',array('catSlug'=>$data->subcategory->category->slug,'subcatSlug'=>$data->subcategory->slug,'slug'=>$data->slug.'.htm'));.

the url is shown as http://localhost/myapp/catSlug/education/subcatSlug/schools/slug/bces.htm

but i want it as http://localhost/myapp/education/schools/bces.htm

and urlManager setting in config main.php is as

‘urlManager’=>array(

		'urlFormat'=>'path',


                    'showScriptName'=>false,


                    'caseSensitive'=>false, 


		'rules'=>array(


                            '<catSlug:\w+>/<subcatSlug:\w+>/<slug:[a-zA-Z0-9-]+>.htm'=>'page/view',


                            'education/<slug:\w+>.htm'=>'page/subCatgoryList',


			'<controller:\w+>/<id:\d+>'=>'<controller>/view',


			'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',


			'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',


                            


                             


		),


	),

where i make the mistake?

Hi Bal,

  1. You have to supply the proper parameters to "createUrl". It should work even when the url format is "get". So the first parameter of "route" should be "page/view", not "/".

  2. You don’t have to (and should not) hard code “.html”. We have a nice “urlSuffix” property for the url manager.




createUrl('page/view', array(

    'catSlug'=>$data->subcategory->category->slug,

    'subcatSlug'=>$data->subcategory->slug,

    'slug'=>$data->slug)

);.






'urlManager'=>array(

	'urlFormat'=>'path',

        'showScriptName'=>false,

        'caseSensitive'=>false, 

        'urlSuffix' => '.html',

	'rules'=>array(

                '<catSlug:\w+>/<subcatSlug:\w+>/<slug:[a-zA-Z0-9-]+>'=>'page/view',

                'education/<slug:\w+>'=>'page/subCatgoryList',

		'<controller:\w+>/<id:\d+>'=>'<controller>/view',

		'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

		'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

	),

),



Solved

Thank you Softark.