Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
20104324
Commit
20104324
authored
Jan 10, 2015
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc fixes [skip ci]
parent
b750cf66
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
10 deletions
+26
-10
helper-url.md
docs/guide/helper-url.md
+6
-6
runtime-routing.md
docs/guide/runtime-routing.md
+7
-0
BaseUrl.php
framework/helpers/BaseUrl.php
+13
-4
No files found.
docs/guide/helper-url.md
View file @
20104324
...
...
@@ -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
...
...
docs/guide/runtime-routing.md
View file @
20104324
...
...
@@ -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()
]
]
...
...
framework/helpers/BaseUrl.php
View file @
20104324
...
...
@@ -52,13 +52,16 @@ class BaseUrl
* - If the route has no leading slash (e.g. `site/index`), it is considered to be a route relative
* to the current module and will be prepended with the module's [[\yii\base\Module::uniqueId|uniqueId]].
*
* Starting from version 2.0.2, a route can also be specified as an alias. In this case, the alias
* will be converted into the actual route first before conducting the above transformation steps.
*
* 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']);
*
* // http://www.example.com/index.php?r=site/index
...
...
@@ -66,6 +69,9 @@ class BaseUrl
*
* // https://www.example.com/index.php?r=site/index
* echo Url::toRoute('site/index', 'https');
*
* // /index.php?r=post/index assume the alias "@posts" is defined as "post/index"
* echo Url::toRoute('@posts');
* ```
*
* @param string|array $route use a string to represent a route (e.g. `index`, `site/index`),
...
...
@@ -154,12 +160,15 @@ class BaseUrl
* Below are some examples of using this method:
*
* ```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.php?r=post/index assume the alias "@posts" is defined as "/post/index"
* echo Url::to(['@posts']);
*
* // the currently requested URL
* echo Url::to();
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment