Home > Backend Development > PHP Tutorial > In Yii2.0, I want to jump from the admin module in the background to the module in the front desk. How to jump?

In Yii2.0, I want to jump from the admin module in the background to the module in the front desk. How to jump?

WBOY
Release: 2016-10-10 11:56:12
Original
1268 people have browsed it

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>
Copy after login
Copy after login

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

Reply content:

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>
Copy after login
Copy after login

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>
Copy after login

Url::to generates a path relative to the current module, while the above method generates an absolute path.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template