Home > Article > Backend Development > In Yii2.0, I want to jump from the admin module in the background to the module in the front desk. How to jump?
The yiihelperUrl::to(); jump
code is as follows. It is now in the background admin module
<code> <a href="<?php echo yii\helpers\Url::to(['product/detail','productid'=>$product->productid]); ?>" class="name"><?php echo $product->title; ?></a> </code>
I want to jump to the detail method of the Product controller in the foreground.
I get an error when I jump. Because there is no such controller and method in the backend module, it cannot be found
The yiihelperUrl::to(); jump
code is as follows. It is now in the background admin module
<code> <a href="<?php echo yii\helpers\Url::to(['product/detail','productid'=>$product->productid]); ?>" class="name"><?php echo $product->title; ?></a> </code>
I want to jump to the detail method of the Product controller in the foreground.
I get an error when I jump. Because there is no such controller and method in the backend module, it cannot be found
<code> <a href="<?php echo Yii::$app->urlManager->createAbsoluteUrl(['product/detail','productid'=>$product->productid]); ?>" class="name"><?php echo $product->title; ?></a> </code>
Url::to generates a path relative to the current module, while the above method generates an absolute path.