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
3c63213d
Commit
3c63213d
authored
Nov 16, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `yii\base\Controller::renderContent()`
parent
439c2e4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
4 deletions
+19
-4
structure-views.md
docs/guide/structure-views.md
+2
-0
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Controller.php
framework/base/Controller.php
+16
-4
No files found.
docs/guide/structure-views.md
View file @
3c63213d
...
@@ -127,6 +127,8 @@ Within [controllers](structure-controllers.md), you may call the following contr
...
@@ -127,6 +127,8 @@ Within [controllers](structure-controllers.md), you may call the following contr
and injects all registered JS/CSS scripts and files. It is usually used in response to AJAX Web requests.
and injects all registered JS/CSS scripts and files. It is usually used in response to AJAX Web requests.
*
[
[yii\base\Controller::renderFile()|renderFile()
]
]: renders a view specified in terms of a view file path or
*
[
[yii\base\Controller::renderFile()|renderFile()
]
]: renders a view specified in terms of a view file path or
[
alias
](
concept-aliases.md
)
.
[
alias
](
concept-aliases.md
)
.
*
[
[yii\base\Controller::renderContent()|renderContent()
]
]: renders a static string by embedding it into
the currently applicable
[
layout
](
#layouts
)
. This method is available since version 2.0.1.
For example,
For example,
...
...
framework/CHANGELOG.md
View file @
3c63213d
...
@@ -52,6 +52,7 @@ Yii Framework 2 Change Log
...
@@ -52,6 +52,7 @@ Yii Framework 2 Change Log
-
Enh #5983: Added
`Inflector::sentence()`
(pana1990, qiangxue)
-
Enh #5983: Added
`Inflector::sentence()`
(pana1990, qiangxue)
-
Enh:
`Console::confirm()`
now uses
`Console::stdout()`
instead of
`echo`
to be consistent with all other functions (cebe)
-
Enh:
`Console::confirm()`
now uses
`Console::stdout()`
instead of
`echo`
to be consistent with all other functions (cebe)
-
Enh:
`yii\rbac\DbManager`
migration now uses database component specified in component settings instead of always using default
`db`
(samdark)
-
Enh:
`yii\rbac\DbManager`
migration now uses database component specified in component settings instead of always using default
`db`
(samdark)
-
Enh: Added
`yii\base\Controller::renderContent()`
(qiangxue)
-
Chg #3630:
`yii\db\Command::queryInternal()`
is now protected (samdark)
-
Chg #3630:
`yii\db\Command::queryInternal()`
is now protected (samdark)
-
Chg #5508: Dropped the support for the
`--append`
option for the
`fixture`
command (qiangxue)
-
Chg #5508: Dropped the support for the
`--append`
option for the
`fixture`
command (qiangxue)
-
Chg #5874: Upgraded Twitter Bootstrap to 3.3.x (samdark)
-
Chg #5874: Upgraded Twitter Bootstrap to 3.3.x (samdark)
...
...
framework/base/Controller.php
View file @
3c63213d
...
@@ -364,17 +364,29 @@ class Controller extends Component implements ViewContextInterface
...
@@ -364,17 +364,29 @@ class Controller extends Component implements ViewContextInterface
*/
*/
public
function
render
(
$view
,
$params
=
[])
public
function
render
(
$view
,
$params
=
[])
{
{
$output
=
$this
->
getView
()
->
render
(
$view
,
$params
,
$this
);
$content
=
$this
->
getView
()
->
render
(
$view
,
$params
,
$this
);
return
$this
->
renderContent
(
$content
);
}
/**
* Renders a static string by applying a layout.
* @param string $content the static string being rendered
* @return string the rendering result of the layout with the given static string as the `$content` variable.
* If the layout is disabled, the string will be returned back.
* @since 2.0.1
*/
public
function
renderContent
(
$content
)
{
$layoutFile
=
$this
->
findLayoutFile
(
$this
->
getView
());
$layoutFile
=
$this
->
findLayoutFile
(
$this
->
getView
());
if
(
$layoutFile
!==
false
)
{
if
(
$layoutFile
!==
false
)
{
return
$this
->
getView
()
->
renderFile
(
$layoutFile
,
[
'content'
=>
$
outpu
t
],
$this
);
return
$this
->
getView
()
->
renderFile
(
$layoutFile
,
[
'content'
=>
$
conten
t
],
$this
);
}
else
{
}
else
{
return
$
outpu
t
;
return
$
conten
t
;
}
}
}
}
/**
/**
* Renders a view.
* Renders a view
without applying layout
.
* This method differs from [[render()]] in that it does not apply any layout.
* This method differs from [[render()]] in that it does not apply any layout.
* @param string $view the view name. Please refer to [[render()]] on how to specify a view name.
* @param string $view the view name. Please refer to [[render()]] on how to specify a view name.
* @param array $params the parameters (name-value pairs) that should be made available in the view.
* @param array $params the parameters (name-value pairs) that should be made available in the view.
...
...
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