mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 13:58:55 +08:00
doc fixes [skip ci]
This commit is contained in:
@ -69,13 +69,13 @@ to the above rules.
|
||||
Below are some examples of using this method:
|
||||
|
||||
```php
|
||||
// /index?r=site/index
|
||||
// /index.php?r=site/index
|
||||
echo Url::toRoute('site/index');
|
||||
|
||||
// /index?r=site/index&src=ref1#name
|
||||
// /index.php?r=site/index&src=ref1#name
|
||||
echo Url::toRoute(['site/index', 'src' => 'ref1', '#' => 'name']);
|
||||
|
||||
// /index?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit"
|
||||
// /index.php?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit"
|
||||
echo Url::toRoute(['@postEdit', 'id' => 100]);
|
||||
|
||||
// http://www.example.com/index.php?r=site/index
|
||||
@ -105,13 +105,13 @@ will be replaced with the specified one.
|
||||
Below are some usage examples:
|
||||
|
||||
```php
|
||||
// /index?r=site/index
|
||||
// /index.php?r=site/index
|
||||
echo Url::to(['site/index']);
|
||||
|
||||
// /index?r=site/index&src=ref1#name
|
||||
// /index.php?r=site/index&src=ref1#name
|
||||
echo Url::to(['site/index', 'src' => 'ref1', '#' => 'name']);
|
||||
|
||||
// /index?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit"
|
||||
// /index.php?r=post/edit&id=100 assume the alias "@postEdit" is defined as "post/edit"
|
||||
echo Url::to(['@postEdit', 'id' => 100]);
|
||||
|
||||
// the currently requested URL
|
||||
|
||||
@ -161,6 +161,10 @@ or an *absolute* route which will be normalized according to the following rules
|
||||
- If the route has no leading slash, it is considered to be a route relative to the current module and
|
||||
will be prepended with the [[\yii\base\Module::uniqueId|uniqueId]] value of the current module.
|
||||
|
||||
Starting from version 2.0.2, you may specify a route in terms of an [alias](concept-aliases.md). If this is the case,
|
||||
the alias will first be converted into the actual route which will then be turned into an absolute route according
|
||||
to the above rules.
|
||||
|
||||
For example, assume the current module is `admin` and the current controller is `post`,
|
||||
|
||||
```php
|
||||
@ -177,6 +181,9 @@ echo Url::to(['post/index']);
|
||||
|
||||
// an absolute route: /index.php?r=post/index
|
||||
echo Url::to(['/post/index']);
|
||||
|
||||
// /index.php?r=post/index assume the alias "@posts" is defined as "/post/index"
|
||||
echo Url::to(['@posts']);
|
||||
```
|
||||
|
||||
The [[yii\helpers\Url::to()]] method is implemented by calling the [[yii\web\UrlManager::createUrl()|createUrl()]]
|
||||
|
||||
Reference in New Issue
Block a user