2015-12-22 132 views
1

enter image description hereyii2(隐藏头,并使用adminLte左侧菜单)

大家好,我想问一下如何隐藏标题和左边的菜单在我的注册表格。我使用adminLte。当我打开登录时,标题和左侧菜单未显示。但是,当我去注册表单,标题和左侧菜单显示。请帮助我们。这里是我的main.php代码

enter code here 

如果(的Yii :: $ APP->控制器 - >动作 - > ID === '登录'){

echo $this->render(
    'main-login', 
    ['content' => $content] 
); 

}其他{

if (Yii::$app->controller->action->id === 'register') { 
    backend\assets\AppAsset::register($this); 
} else { 
    backend\assets\AppAsset::register($this); 
} 
dmstr\web\AdminLteAsset::register($this); 

$directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'); 
?> 
<?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() ?> 
</head> 
<!-- <body class="skin-blue sidebar-mini"> --> 
<body class="<?= AdminLteHelper::skinClass() ?> fixed"> 
<?php $this->beginBody() ?> 
<div class="wrapper"> 

    <?= $this->render(
     'header.php', 
     ['directoryAsset' => $directoryAsset] 
    ) ?> 

    <?= $this->render(
     'left.php', 
     ['directoryAsset' => $directoryAsset] 
    ) 
    ?> 

    <?= $this->render(
     'content.php', 
     ['content' => $content, 'directoryAsset' => $directoryAsset] 
    ) ?> 

</div> 

回答

0

是的,因为您只为登录操作添加条件。 所以它只加载main-login.php内容。 您已经添加了另一个条件,然后再折页。

我觉得下面的变化将有助于全为您

<?php 
     use yii\helpers\Html; 

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


     if (Yii::$app->controller->action->id === 'login') { 
      echo $this->render(
       'main-login', 
       ['content' => $content] 
      ); 
     }  
    else if (Yii::$app->controller->action->id === 'sign-in') { 
       echo $this->render(
        'main-login', 
        ['content' => $content] 
       ); 
      } 
    else { 

      if (class_exists('backend\assets\AppAsset')) { 
       backend\assets\AppAsset::register($this); 
      } else { 
       app\assets\AppAsset::register($this); 
      } 

      dmstr\web\AdminLteAsset::register($this); 

      $directoryAsset = Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'); 
      ?> 
      <?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() ?> 
      </head> 
      <body class="hold-transition skin-blue sidebar-mini"> 
      <?php $this->beginBody() ?> 
      <div class="wrapper"> 

       <?= $this->render(
        'header.php', 
        ['directoryAsset' => $directoryAsset] 
       ) ?> 

       <?= $this->render(
        'left.php', 
        ['directoryAsset' => $directoryAsset] 
       ) 
       ?> 

       <?= $this->render(
        'content.php', 
        ['content' => $content, 'directoryAsset' => $directoryAsset] 
       ) ?> 

      </div> 

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

所以别人如果以上条件,我们仅是通过动作登录呈现内容加载主登录。

相关问题