Ejemplo n.º 1
0
Archivo: main.php Proyecto: npk/v2sex
NavBar::begin(['brandLabel' => Yii::$app->name, 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-default']]);
$keyword = isset($this->context->keyword) ? $this->context->keyword : '';
echo '<form class="navbar-form navbar-left" role="search" action="/search" method="get">
                <div class="form-group">
                    <input type="text" value="' . $keyword . '" name="keyword" class="form-control search_input" id="navbar-search" placeholder="搜索..." data-placement="bottom" data-content="请输入要搜索的关键词!">
                </div>
            </form>';
if (Yii::$app->user->isGuest) {
    $menuItems[] = ['label' => '注册', 'url' => ['/account/signup']];
    $menuItems[] = ['label' => '登录', 'url' => ['/account/login']];
} else {
    $menuItems[] = ['label' => Yii::$app->user->identity->username, 'url' => ['/member/' . Yii::$app->user->identity->username]];
    if (Yii::$app->user->identity->email_status == 1) {
        $menuItems[] = ['label' => '创作新主题', 'url' => ['/topic/create']];
    }
    $menuItems[] = ['label' => '通知 <span class="badge badge-important">' . Notice::Count() . '</span>', 'url' => ['/account/notice']];
    $menuItems[] = ['label' => '设置', 'url' => ['/account/setting']];
    $menuItems[] = ['label' => '退出', 'url' => ['/account/logout'], 'linkOptions' => ['data-method' => 'post']];
}
echo Nav::widget(['encodeLabels' => false, 'activateItems' => false, 'options' => ['class' => 'navbar-nav navbar-right'], 'items' => $menuItems]);
NavBar::end();
?>
    </header>
    <main id="Wrapper" style="<?php 
if (!empty($this->context->bg)) {
    echo 'background-image:url(' . Yii::$app->params['bgUrl'] . $this->context->bg . ');background-position: 0 0, 0 0;background-repeat: repeat;';
}
if (!empty($this->context->bg_color)) {
    echo 'background-color:' . $this->context->bg_color;
}
?>
Ejemplo n.º 2
0
<?php

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use frontend\assets\AppAsset;
use common\models\Notice;
/* @var $this \yii\web\View */
/* @var $content string */
AppAsset::register($this);
$noticeCount = Notice::Count();
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title><?php 
echo Html::encode($this->context->title);
if ($noticeCount > 0) {
    echo ' (' . $noticeCount . ')';
}
?>