<bdo id='ke8RN'></bdo><ul id='ke8RN'></ul>

    <small id='ke8RN'></small><noframes id='ke8RN'>

    <tfoot id='ke8RN'></tfoot>

    1. <i id='ke8RN'><tr id='ke8RN'><dt id='ke8RN'><q id='ke8RN'><span id='ke8RN'><b id='ke8RN'><form id='ke8RN'><ins id='ke8RN'></ins><ul id='ke8RN'></ul><sub id='ke8RN'></sub></form><legend id='ke8RN'></legend><bdo id='ke8RN'><pre id='ke8RN'><center id='ke8RN'></center></pre></bdo></b><th id='ke8RN'></th></span></q></dt></tr></i><div id='ke8RN'><tfoot id='ke8RN'></tfoot><dl id='ke8RN'><fieldset id='ke8RN'></fieldset></dl></div>
    2. <legend id='ke8RN'><style id='ke8RN'><dir id='ke8RN'><q id='ke8RN'></q></dir></style></legend>

    3. 如何将参数从控制器传递到 YII2 中的布局

      How to pass param from controller to layout in YII2(如何将参数从控制器传递到 YII2 中的布局)
          <bdo id='5YQqJ'></bdo><ul id='5YQqJ'></ul>

          <small id='5YQqJ'></small><noframes id='5YQqJ'>

        • <i id='5YQqJ'><tr id='5YQqJ'><dt id='5YQqJ'><q id='5YQqJ'><span id='5YQqJ'><b id='5YQqJ'><form id='5YQqJ'><ins id='5YQqJ'></ins><ul id='5YQqJ'></ul><sub id='5YQqJ'></sub></form><legend id='5YQqJ'></legend><bdo id='5YQqJ'><pre id='5YQqJ'><center id='5YQqJ'></center></pre></bdo></b><th id='5YQqJ'></th></span></q></dt></tr></i><div id='5YQqJ'><tfoot id='5YQqJ'></tfoot><dl id='5YQqJ'><fieldset id='5YQqJ'></fieldset></dl></div>

                <tbody id='5YQqJ'></tbody>
              <legend id='5YQqJ'><style id='5YQqJ'><dir id='5YQqJ'><q id='5YQqJ'></q></dir></style></legend>
              1. <tfoot id='5YQqJ'></tfoot>

                本文介绍了如何将参数从控制器传递到 YII2 中的布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想将参数从控制器发送到布局(即 main.php).但是我无法在 main.php 中获取参数

                I want to send a parameter from controller to layout (i.e. main.php). But I am not able to get the param in main.php

                我试过:

                控制器代码:

                $this->render('index',array('param' => $paramValue));
                

                这就是我试图在布局中获得它的方式,即.main.php

                And this is how i was trying to get this in layout ie. main.php

                1. $this->param(如 yii 1)
                2. $param
                1. $this->param (as in yii 1)
                2. $param

                但是我无法在布局中获取参数值.谁能告诉我怎么做?

                But i am not able to get param value in layout. Can anyone tell me how to do this?

                推荐答案

                yiiaseView 有特殊的 $params 属性.

                例如,它用于使用 Gii 在默认生成的 CRUD 代码模板中构建面包屑.

                For example it's used for building breadcrumbs in default generated CRUD code templates with Gii.

                渲染前可以这样设置:

                use Yii;
                
                Yii::$app->view->params['customParam'] = 'customValue';
                

                在控制器中,您可以这样设置:

                Inside a controller you can set it like this:

                $this->view->params['customParam'] = 'customValue';
                

                然后它将在视图中可用(包括主布局):

                Then it will be available in views (including main layout):

                /* @var $this yiiwebView */
                
                echo $this->params['customParam'];
                

                您也可以在官方指南.

                这篇关于如何将参数从控制器传递到 YII2 中的布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                Joomla include database functions(Joomla 包含数据库功能)
                nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)

              2. <tfoot id='GB0JA'></tfoot>

                  <tbody id='GB0JA'></tbody>
                • <bdo id='GB0JA'></bdo><ul id='GB0JA'></ul>
                  <legend id='GB0JA'><style id='GB0JA'><dir id='GB0JA'><q id='GB0JA'></q></dir></style></legend>
                • <i id='GB0JA'><tr id='GB0JA'><dt id='GB0JA'><q id='GB0JA'><span id='GB0JA'><b id='GB0JA'><form id='GB0JA'><ins id='GB0JA'></ins><ul id='GB0JA'></ul><sub id='GB0JA'></sub></form><legend id='GB0JA'></legend><bdo id='GB0JA'><pre id='GB0JA'><center id='GB0JA'></center></pre></bdo></b><th id='GB0JA'></th></span></q></dt></tr></i><div id='GB0JA'><tfoot id='GB0JA'></tfoot><dl id='GB0JA'><fieldset id='GB0JA'></fieldset></dl></div>

                    <small id='GB0JA'></small><noframes id='GB0JA'>