Hello,
I ran into an odd problem with CTreeView. I want to set up a tree so that each node is hyperlinked and points to a parameterized controller/action. In order to provide the data I have provided the model with the following methods:
public function buildTree()
{
return array($this->buildNode());
}
public function buildNode()
{
return array(
'text' => $this->createLink(),
// additional params
);
}
public function createLink()
{
return CHtml::link(CHtml::encode("test"), array('controller/view', 'id'=>1));
}
The controller gathers the data:
public function actionView($id)
{
$model = $this->loadModel($id);
$treeDataProvider = $model->buildTree();
$this->render('view',array(
'model'=>$model,
'treeDataProvider' => $treeDataProvider,
));
}
And the view looks like this:
echo $model->createLink();
$this->widget('system.web.widgets.CTreeView', array(
'data' => $treeDataProvider,
));
On my development machine (W7 64bit Apache 2 PHP5.3.6 Yii 1.1.9) both the urls are identical, but on the webserver (Linux, apache 2, php 5.2.17, yii 1.1.9) the echoed url generated by createLink is correct (/controller/1), but the url in the treeview looks like
/controller/0[id]/1.
I do not understand what is causing this discrepancy. Both urls are generated by the same code. Am I overlooking something?
Thanks in advance,
Ritch