kartik-v / yii2-tree-manager

An advanced tree management module using nested sets for Yii 2.
http://demos.krajee.com/tree-manager
Other
150 stars 107 forks source link

treemanager route link issue #230

Closed scmember closed 5 years ago

scmember commented 5 years ago

Hello!

Added a button to root node which implements an action, just like this:

<?= Html::a('Action', ['controller/action', 'id' => $node->node_id], ['class' => 'btn btn-info']) ?>

image

When I open tree manager window for a first time, the first root node is selected by default, and the button link of a node looks like: http://server/index.php?r=controller%2Faction&id=1 It's ok.

But if I select any other root node (for eample 35), the button link of this node looks like: http://server/index.php?r=treemanager%2Fcontroller%2Faction&id=35

Then if I try to return to the first root node, its button link changes to http://server/index.php?r=treemanager%2Fcontroller%2Faction&id=1

What is the right way to set a route for the button? Thanks

kartik-v commented 5 years ago

Since treemanager is a module - the controller and action routes will be module specific prefixed by module name (if you use a relative route without preceding forward slash). This is more an Yii2 URL configuration. You need to use the absolute right action with a preceding forward slash in such cases:

For example you should change and correct your button action to following:

<?= Html::a('Action', ['/controller/action', 'id' => $node->node_id], ['class' => 'btn btn-info']) ?>

NOTE the preceding forward slash / before the controller (assuming the controller is in your root app.

scmember commented 5 years ago

damn it's so simple!

Thank you very much!