【问题标题】:PHP YII 2 why when i add new page, it's not showing nothing?PHP YII 2 为什么当我添加新页面时,它什么也没显示?
【发布时间】:2016-10-31 04:36:03
【问题描述】:

我想在 yii2 中添加一些带有 layouts->main.php 的新页面,如下所示:

<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\web\View;
use yii\helpers\Url;    

$this->registerJsFile("@web/js/modernizr.custom.js");
$this->registerJsFile("@web/js/classie.js");
$this->registerCssFile( "/css/animate.css" );
$this->registerCssFile( "/css/sliding/component.css" );
$this->registerCssFile( "/css/sliding/default.css" );

$js = <<< 'SCRIPT'


SCRIPT;

$this->registerJs( $js, yii\web\View::POS_READY );  


AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?= Html::csrfMetaTags() ?>
<title><?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
<style type="text/css">
    body
    {
        font-family: arial;
        background-color : #e6e3e3;
    }

    .glyphicon {
        font-size: 25px;
    }
</style>
</head>
<body class="cbp-spmenu-push">
<?php $this->beginBody() ?>

<div class="wrap">

<div id="bar-top" class="bar-top">
    <div class="container" style='margin-right:auto;'>
        <div class="row">
            <div class="col-xs-1" 
            style="font-size: 24px;margin-top:6px; color:white; text-align:    center;font-family: Arial;font-weight: bold;text-transform: none;">T@POP CENTRAL MANAGEMENT SYSTEM
            </div>
            <div id="User" class="col-xs-11" style="font-size: 18px;margin- top:14px; color:white; text-align: right;font-family: Arial, Helvetica, sans-serif;font-weight: bold;text-transform: none;padding-left: 95px;"><label>User&nbsp;<span class="glyphicon glyphicon-user"></span></label>
            </div>
        </div>
    </div>
</div>

  <div class="contain"> 
      <div><a href="a"><span style="margin-top: 10px" class="glyphicon glyphicon-home">&nbsp;</span><span>Dashboard</span></a></div>

          <div class="dropdown"><a><span style="margin-top: 10px" class="glyphicon glyphicon-blackboard">&nbsp;</span><span>Programming</span></a>         

              <div class="dropdown_4columns"> 

                      <div class="col_1">
                        <h3>EAN</h3>
                            <ul>
                                <li><a href="#"><label>EAN Data</label></a></li>
                                <li class="retail"><a href="#"><label>Batch Price</label></a></li>
                                <li class="pos"><a href="#"><label>Tag Link</label></a></li>
                            </ul> 
                      </div>

                      <div class="col_1">
                          <h3>Design</h3>
                              <ul>
                                  <li class="retail"><a href="#"><label>Graphic Tag Design</label></a></li>
                              </ul> 
                      </div>

                      <div class="col_1">
                          <h3>POS</h3>
                              <ul>
                                  <li><a href="#"><label>File Structure</label></a></li>
                                  <li class="retail"><a href="#"><label>File Definition</label></a></li>
                                  <li class="pos"><a href="#"><label>Field Definition</label></a></li>
                              </ul> 
                      </div>

                      <div class="col_1">
                          <h3>OTHERS</h3>
                              <ul>
                                  <li><a href="#"><label>Add/Edit Store</label></a></li>
                                  <li class="retail"><a href="#"><label>IP Address Setup</label></a></li>
                                  <li class="pos"><a href="#"><label>Group/Sub Group</label></a></li>
                                  <li class="pos"><a href="#"><label>User</label></a></li>
                              </ul> 
                      </div>

            </div>  

        </div>

          <div class="dropdown"><a><span style="margin-top: 10px" class="glyphicon glyphicon-cog">&nbsp;</span><span>Configuration</span></a>         

              <div class="dropdown_4columns"> 

                  <div class="col_1">
                      <h3>Configuration</h3>
                      <ul>
                          <li><a href="#"><label>Environment</label></a></li>
                          <li class="retail"><a href="#"><label>Store Configuration</label></a></li>
                      </ul> 
                  </div>

              </div>  

          </div>

          <div class="dropdown">
              <a>
                  <span style="margin-top: 10px" class="glyphicon glyphicon-globe">&nbsp;</span>
                  <span>Utility</span>
              </a>
          </div>
          <div class="dropdown">
              <a>
                  <span style="margin-top: 10px" class="glyphicon glyphicon-search">&nbsp;</span>
                  <span>Monitoring</span>
              </a>
          </div>
          <div class="dropdown">
              <a>
                  <span style="margin-top: 10px" class="glyphicon glyphicon-log-out">&nbsp;</span>
                  <span>Logout</span>
              </a>
          </div>  
  </div>    


   <?php $this->endBody() ?>
   </body>
   </html>
   <?php $this->endPage() ?>

当我使用这个main.php 时,我无法在yii2 中添加新页面,

当我添加新的page 时,我创建新的controllerview 只是为了测试创建新的page,它不会向display 显示任何内容,

为什么会这样?

这样可以解决吗?

当我将main.php 更改为旧版本(default)时,可以显示新的page 我已被创建。

所以,我想创建新的page 并显示它,同时也使用这个main.php

提前致谢

问候。

【问题讨论】:

    标签: php html css yii


    【解决方案1】:

    如果你只想使用不同的布局,你可以在控制器/动作中使用$this->layout 这样做

      public function actionYourAction()
      {
          ........
    
          $this->layout = 'your_new_layout';
    
          return $this->render('your_view', [
              'searchModel' => $searchModel,
              'dataProvider' => $dataProvider,
          ]);
    
      }
    

    【讨论】:

      【解决方案2】:

      我找到了答案,我找到了这个代码和那个:

      <div class="container-fluid" style="margin-top: 100px">
      <?= Breadcrumbs::widget([
        'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        'options' => ['class' => 'breadcrumb', 'style' => 'background-color:#efebeb'],
        ]) ?>
      <?= $content ?>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-10-01
        • 2020-01-16
        • 2017-09-03
        • 2021-05-07
        • 1970-01-01
        • 2017-04-30
        相关资源
        最近更新 更多