0
<?php echo CHtml::link($value->title, array(Yii::app()->createUrl('forum/thread', array('id'=>$value->thread_id)))); ?>

i got a link

forum/thread/2

in my urlManager rules 'thread/<id:\d+>' => 'forum/thread',

how to change the rule and method createUrl?

createUrl('any-value/forum/thread', array('id'=>$value->thread_id))

to get in url

forum/any-value/thread/2 or forum/php-for-newbies/thread/2

I am sorry for my english, thanks a lot

Michael Härtl
  • 8,428
  • 5
  • 35
  • 62
Dima
  • 7
  • 5

2 Answers2

0

Try this: 'forum/any-value/thread/<id:\d+>' => 'any-value/forum/thread',

and with this: createUrl('any-value/forum/thread', array('id'=>$value->thread_id)) So you should get forum/any-value/thread/2

that should work!

But If you are inside the module called forum then you would do like that:

'any-value/thread/<id:\d+>' => 'any-value/forum/thread',

and with this: createUrl('any-value/forum/thread', array('id'=>$value->thread_id))

Elbek
  • 3,434
  • 6
  • 37
  • 49
0

URL Manager rule should look like this:

'forum/<title:\w+>/thread/<id:\d+>' => 'forum/thread', //make sure this is listed first so it has priority
'thread/<id:\d+>' => 'forum/thread',

Then in your controller you would have this:

public function actionThread($id,$title=null) {
    //$title will contain title from url if sent
}
Pitchinnate
  • 7,517
  • 1
  • 20
  • 37