how i achieve the url ourdomain/dynamic_value ?
for eg: http://www.yiiframework.com/rajith
another
http://www.yiiframework.com/sajith
etc
any tested solution?
how i achieve the url ourdomain/dynamic_value ?
for eg: http://www.yiiframework.com/rajith
another
http://www.yiiframework.com/sajith
etc
any tested solution?
Dear Rajith
Obviously we have to inject the names into GET parameters.
Consider we have a Model User.
Then we can create url like this.
views/user/_view.php
<div class="view">
<b><?php echo CHtml::encode($data->getAttributeLabel('username')); ?>:</b>
<?php echo CHtml::link(CHtml::encode($data->username), array('view', 'name'=>$data->username)); ?>
<br />
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('password')); ?>:</b>
<?php echo CHtml::encode($data->password); ?>
<br />
<b><?php echo CHtml::encode($data->getAttributeLabel('email')); ?>:</b>
<?php echo CHtml::encode($data->email); ?>
<br />
</div>
Then UserController::actionView is modified like this.
public function actionView($name)
{ $model=User::model()->findByAttributes(array('username'=>$name));
$this->render('view',array(
'model'=>$model,
));
}
Then we can add a url rule like this.
'urlManager'=>array(
'urlFormat'=>'path',
'showScriptName'=>false,
'rules'=>array(
'<name:\w+>'=>'user/view',
...other rules to follow...
I hope I helped a bit.
Regards.
okay… thank u… i will try it and get back.