• <tfoot id='v5W3r'></tfoot>

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

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

        Yii2 前后端链接(高级模板)

        时间:2023-10-16
        <legend id='4xK0D'><style id='4xK0D'><dir id='4xK0D'><q id='4xK0D'></q></dir></style></legend>

              • <bdo id='4xK0D'></bdo><ul id='4xK0D'></ul>

                <tfoot id='4xK0D'></tfoot>
                <i id='4xK0D'><tr id='4xK0D'><dt id='4xK0D'><q id='4xK0D'><span id='4xK0D'><b id='4xK0D'><form id='4xK0D'><ins id='4xK0D'></ins><ul id='4xK0D'></ul><sub id='4xK0D'></sub></form><legend id='4xK0D'></legend><bdo id='4xK0D'><pre id='4xK0D'><center id='4xK0D'></center></pre></bdo></b><th id='4xK0D'></th></span></q></dt></tr></i><div id='4xK0D'><tfoot id='4xK0D'></tfoot><dl id='4xK0D'><fieldset id='4xK0D'></fieldset></dl></div>
                  <tbody id='4xK0D'></tbody>
              • <small id='4xK0D'></small><noframes id='4xK0D'>

                  本文介绍了Yii2 前后端链接(高级模板)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我需要从菜单的后端部分(或从后端到管理员)添加到前端内容的链接,我如何在没有硬编码的情况下做到这一点?这:

                  If i need add links to frontend stuff from backend part in menu(or from backend to admin), how i can do this without hardcode? This:

                   Yii::$app->request->BaseUrl 
                  

                  从父目录返回路径

                  /sitename/backend/web
                  /sitename/frontend/web
                  

                  推荐答案

                  在您的后端应用程序配置中,您应该添加额外的 'UrlManager' 组件,其名称和配置与前端应用程序中使用的相同:

                  In your backend application config you should add additional 'UrlManager' component with different name and configuration equals to the one used at front end application:

                  return [
                      'components' => [
                          'urlManager' => [
                              // here is your backend URL rules
                          ],
                          'urlManagerFrontEnd' => [
                              'class' => 'yiiweburlManager',
                              'baseUrl' => '/a/frontend/web',
                              'enablePrettyUrl' => true,
                              'showScriptName' => false,
                          ],
                  
                      ],
                  ];
                  

                  那么您应该调用以下内容来编写前端 URL:

                  Then you should invoke following to compose front-end URL:

                  Yii::$app->urlManagerFrontEnd->createUrl();
                  

                  这篇关于Yii2 前后端链接(高级模板)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:模型->save() 在 Yii2 中不起作用 下一篇:在 Yii 2 中将多个数据插入数据库

                  相关文章

                  • <bdo id='inoA4'></bdo><ul id='inoA4'></ul>
                  1. <small id='inoA4'></small><noframes id='inoA4'>

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

                    1. <legend id='inoA4'><style id='inoA4'><dir id='inoA4'><q id='inoA4'></q></dir></style></legend>