Yii2 AdminLte Iframe Mode
for V2.0
。 Not compatible for before !!
The preferred way to install this extension is through composer.
Either run
php composer.phar require kriss/yii2-adminlte-iframe-mode -vvv
or add
"kriss/yii2-adminlte-iframe-mode": "^2.0"
to the require section of your composer.json
file.
- 增加配置
<?php
use kriss\iframeLayout\component\IframeMode;
return [
'components' => [
IframeMode::COMPONENT_NAME => [
'class' => IframeMode::class,
'enable' => true,
'defaultSwitch' => true,
],
]
];
- 在基础控制器中增加
behavior
<?php
use kriss\iframeLayout\filter\IframeLinkFilter;
public function behaviors()
{
$behaviors = parent::behaviors();
$behaviors['iframe_layout'] = [
'class' => IframeLinkFilter::className(),
//'layout' => '@app/views/layouts/main-content', // 使用该参数自定义布局
];
return $behaviors;
}
布局参考: /views/main-content.php
- 在默认的布局文件
(main.php)
中增加Asset
<?php
\kriss\iframeLayout\widget\IframeModeAssetWidget::widget();
-
在上面的操作基础上
-
在某个控制器,比如
SiteController
中增加action
<?php
use kriss\iframeLayout\action\IframeModeSwitchAction;
public function actions()
{
return [
// 其他 actions
'iframe-mode-switch' => [
'class' => IframeModeSwitchAction::className(),
]
];
}
- 增加切换模式的链接按钮
<?= \kriss\iframeLayout\widget\IframeModeSwitchWidget::widget() ?>